首页 > 编程知识 正文

webservice服务端开发,webservice两种模式

时间:2023-05-06 07:18:45 阅读:37020 作者:4462

记录webservice接口访问服务端通常会给出http://xxx/services.asmx。

以前,wsdl创建服务端,使用idea附带的工具生成客户端,或使用wsdl2java工具生成客户端。

在网上找了各种各样的方法,终于成功了。

服务端URL: asmx的请求和响应代码: ---请求----post/web服务/services/webserviceimplservice.asmx http/1.1 host :172.16.1.20 content-type 3360 teen t charset=utf-8 content-length : length soap action 3360 ' http://web服务soap : envelope xmlns 3360 xsi=' http://www.w3.org/2001/XML方案实例' xmlns 3360 xsd=' http://ww.w3.org/XML方案' xmlns 3360 soap=' http://方案. XML soap.org/soap/envelope/' soap 3360 bodysendinfoxmlns=' 3358 web服务web ---响应----http/1.1200 ok content-type : text/XML; charset=utf-8内容长度:长度? XML版本=' 1.0 '编码=' utf-8 '? soap : envelope xmlns 3360 xsi=' http://www.w3.org/2001/XML方案实例' xmlns 3360 xsd=' http://ww.w3.org/XML方案' xmlns 3360 soap=' http://方案. XML soap.org/soap/envelope/' soap 3360 bodysendinforesponsexmlns=' 3358 webbbbbmlop sendinforesult/sendinforesponse/soap 3360 body/soap : envelope方法一asmx也可以在asmx中使用,http://xxx/services.asmx之后是http://www 生成方式是百度,有很多。 这么简单就写不了这篇文章/哭

我这个服务端的地址包括很多方法。 其中一些参数在由wsdl2java工具生成时报告给特定字段。 我在网上找到了可以用wsdl2java生成的asmx文件。 所以不能使用这个方法。

方法直接使用2?wsdl和http://www.Sina.com/。 代码如下。

publicstaticvoidmain (string [ ] args ) throws exception (string URL=' http://IP 3360端口/web服务/services/web服务/! stringnamespace='http://web服务/服务/webserviceimplservice '; //action路径(方法名称) String actionUri='SendInfo '; //方法名称String op='SendInfo '; 服务服务=新服务(呼叫呼叫=(呼叫)服务. create call ); call.settargetendpointaddress (newurl ); call.setusesoapaction(true; 创建//QName对象时,qname类生成方法的第一个参数是WSDL文件的命名空间名称,即wsdl:definitions元素的targetNamespace属性值call.setsoapactions call.setoperationname(newqname ) namespace,op ); //要调用的方法call.addparameter(newqname ) namespace、' Data )、//要传递的参数)形式参考) XMLType.XSD_STRING,parametermode object [ ] params=new object [ ] { JSON }; String response=' '; try{response=(string ) call.invoke ) Params; 调用//方法并传递参数}catch(exceptione ) {e.printStackTrace ); SOAP发送的请求消息system.out.println (-- soap request : ' call.getmessage context ).getRequestMessage ).getsoapppe }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。