如何在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
方法,问题是访问同一文件中的另一个方法。