cxf 客户端调用gsoap生成的服务


cxf 客户端调用gsoap生成的服务

---》下载 cxf并解压,进入cxf的bin目录下执行如下命令

wsdl2java  -frontend jaxws21 -p com.test -d E:\codeTest\myCXF -client http://127.0.0.1:50001?wsdl


wsdl2java -p com.test -d E:\codeTest\myCXF -client  E:\codeTest\myCXF\xxxx.wsdl

参数解释:
-frontend jaxws21
若不加这个参数 有几处的super地方报错
错误原因:由于jax-ws2.2规约与java6冲突  故需要降低jax-ws规约版本
解决方法:在生成的时候服务路径前面加上 -frontend jaxws21
http://blog.csdn.net/wangnetkang/article/details/7821294


-p 生成包
-d 生成的包存放路径
-client 生成客户端调用代码
**.wsdl  wsdl路径

---》建立工程,把cxf下的lib下的tar加入工程,并把生成的com.test加入工程。
---》自动生成的代码中有个自动生成调用的类(可以在工程下搜一下main方法就知道是那个类了:D )
---》另:用gsaop生成服务端的时候

//gsoap ns service name: xxxx
//gsoap ns service namespace: http://websrv.cs.fsu.edu/~engelen/xxxx.wsdl
//gsoap ns service location: http://websrv.cs.fsu.edu/~engelen
//gsoap ns service executable: xxxx.cgi
//gsoap ns schema namespace: urn:xxxx


由于gsoap ns service location 是随便写的,以为只是命名空间,导致了如下错误:

Caused by: java.net.ConnectException: ConnectException invoking http://websrv.cs.fsu.edu/~engelen/xxxx.cgi: Connection timed out: connect
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)


改成如下,就可以。

//gsoap ns service name: xxxx
//gsoap ns service namespace: http://127.0.0.1:50001?xxxx.wsdl
//gsoap ns service location: http://127.0.0.1:50001
//gsoap ns service executable: xxxx.cgi
//gsoap ns schema namespace: urn:xxxx


---》再另:gsoap生成wsdl文件

  <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
      去掉schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" ,wsdl2java否则无法解析,报如下错误:

WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsd
l definition from : http://127.0.0.1:50001?wsdl
Caused by : WSDLException: faultCode=PARSER_ERROR: Problem parsing 'http://127.0
.0.1:50001?wsdl'.: java.net.ConnectException: Connection refused: connect

你可能感兴趣的:(CXF,企业应用,SOAP)