从.Net调用使用List <T>的Java Web Service,需要遵循以下步骤:
以下是一个简单的示例:
import java.util.List;
public interface MyService {
public List<String> getData();
}
using System.Web.Services;
[WebServiceBinding(Name = "MyServiceSoapBinding", Namespace = "http://www.example.com/")]
public class MyService : System.Web.Services.Protocols.SoapHttpClientProtocol {
public MyService() {
this.Url = "http://example.com/MyService?wsdl";
}
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace = "http://www.example.com/", ResponseNamespace = "http://www.example.com/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public List<string> getData() {
object[] results = this.Invoke("getData", new object[0]);
return ((List<string>)(results[0]));
}
}
MyService service = new MyService();
List<string> data = service.getData();
这样就可以在.Net项目中调用Java Web Service的接口,并获取返回的List <T>数据了。
领取专属 10元无门槛券
手把手带您无忧上云