这是一个用Java调用C#版WebService接口的例子:
C#接口:
- <SPAN style="FONT-SIZE: 11px">
- using System;
- using System.Web;
- using System.Web.Services;
- using System.Web.Services.Protocols;
- using System.Web.Services.Description;
- [WebService(Namespace = "http://www.tangs.com/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- public class Service : System.Web.Services.WebService
- {
- public Service () ...{
- //如果使用设计的组件,请取消注释以下行
- //InitializeComponent();
- }
- [SoapRpcMethod(Action = "http://www.tangs.com/Add", RequestNamespace = "http://www.tangs.com/T", ResponseNamespace = "http://www.tangs.com/T", Use = SoapBindingUse.Literal)]
- [WebMethod]
- public int Add(int a, int b)
- ...{
- return a + b;
- }
- [SoapRpcMethod(Action = "http://www.tangs.com/Hello", RequestNamespace = "http://www.tangs.com/T", ResponseNamespace = "http://www.tangs.com/T", Use = SoapBindingUse.Literal)]
- [WebMethod]
- public String HelloWorld()
- ...{
- return "Hello, world!";
- }
- }
- ...</SPAN>