Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Java小程序中调用WebMethod_Java_C#_Webmethod - Fatal编程技术网

如何在Java小程序中调用WebMethod

如何在Java小程序中调用WebMethod,java,c#,webmethod,Java,C#,Webmethod,如何在我的Javaapplet中调用C#WebMethod C中名为EnrollClient的方法# 我的尝试 public void enroll(String teste) { URL u; InputStream is = null; try { u = new URL("http://localhost:5154/lb.ashx?pwd=abci/EnrollClient");

如何在我的
Javaapplet
中调用C#
WebMethod

C中名为
EnrollClient
的方法#

我的尝试

    public void enroll(String teste) {
       URL u;
       InputStream is = null;             

       try {
           u = new URL("http://localhost:5154/lb.ashx?pwd=abci/EnrollClient");
           is = u.openStream();
           BufferedReader d = new BufferedReader(new InputStreamReader(is));
       } catch (MalformedURLException mue) {              
               mue.printStackTrace();                 
         } catch (IOException ioe) {             
               ioe.printStackTrace();                
         } finally {
              try {
                    is.close();             
              } catch (IOException ioe) {               
         }
    }   
C#WebMethod

public class lb : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";                        
        strings pwd = context.Request["pwd"].ToString();
        business.Client.lb cli = new business.Client.lb();

        JavaScriptSerializer jss = new JavaScriptSerializer();
        StringBuilder sbRes = new StringBuilder();                        
        jss.Serialize(cli.ReturnJSon(), sbRes);

        context.Response.Write(sbRes.ToString());
    }

    [WebMethod]
    public void EnrollClient()
    {
        string template = string.Empty;
        string client = string.Empty;
        try
        {
            business.Client.lb cli = new business.Client.lb();
            cli.EnrollClient(template, client);                                                
        }
        catch (Exception e)
        {
        }
    }
如果我使用相同的代码但使用相同的代码

u=新URL(“http://localhost:5154/lb.ashx?pwd=abci");


它将访问我的C#code的
ProcessRequest

您是否对小程序进行了签名?不,我没有,但我可以执行以下代码:
http://localhost:5154/lb.ashx?pwd=abci
它工作正常,但我将访问此
.ashx
文件的
main
方法,我需要访问一个名为
EnrollClient
的特定方法,这可能会帮助您@真的有必要吗?我问这个问题是因为我可以从
lb.ashx
文件访问
processrequest
方法,问题是访问同一文件中的另一个方法。