您的位置:首页 > 编程语言 > Java开发

.net写的WebService被Java调用

2011-09-26 08:35 344 查看
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);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息