Java调用.net的WebService时有参无参都可以成功:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
[SoapDocumentService(RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
public class Service : System.Web.Services.WebService {
public Service()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
/// <summary>
/// 对服务调用的基本测试(无参函数)
/// </summary>
/// <returns></returns>
[WebMethod]
[SoapRpcMethod(Use = SoapBindingUse.Literal, RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/")]
public string HelloWorld()
{
return "HelloWorld!";
}
[WebMethod]
[SoapRpcMethod(Use = SoapBindingUse.Literal, RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/")]
public string HelloArgs(string str, int n)
{
return string.Format("HelloArgs! str:{0}, n:{1}", str, n);
}
}