1、引用添加处
image2、查找WSDL服务
image点击“转到”查找服务,假如服务格式不正确,则会发生错误
注:服务地址必须以“?wsdl”结尾,否则无法找到以WSDL(网络服务描述语言,Web Services Description Language)约束的XML接口文档
image3、如何找到正确地址
有时发布的Java WebService的地址(如 http://192.168.183.9:8080/webService/services/WbService)不一定能够找到,此时可以通过在浏览器中访问并跳转来找到WSDL访问地址
image4、服务声明与方法调用
WbService.WbServicePortTypeClient webClient = new WbService.WbServicePortTypeClient();
if (webClient.State != System.ServiceModel.CommunicationState.Opened)
webClient.Open();
bool result = webClient.save_gps_machines("1", 0, 0);
5、服务引用动态声明
image imagestring service_ip = "192.168.183.9";
string port = "8080";
string address = string.Format("http://{0}:{1}/webService/services/IWbService", service_ip, port);
WbService.WbServicePortTypeClient webClient = new WbService.WbServicePortTypeClient("IWbServiceHttpPort", address);
网友评论