我使用WSDL2Java生成了一组类,并构建了一个测试客户端来尝试调用SOAP服务。
生成类,但是当我调用Web服务时,我注意到出站消息的final TextView text=convertView.findViewById(R.id.textview);
final SeekBar seekbar=(SeekBar) convertView.findViewById(R.id.seekBar1);
sk.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
// TODO Auto-generated method stub
text.setText(progress);
}
});
为空。
以下是我得到的一些信息:
Ant脚本
body
客户端代码
<target depends="clear-cxf-client-src" name="cxf-wsdl-java">
<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
<arg value="-client"/>
<arg value="-d"/>
<arg value="${src.dir}"/>
<arg value="-exsh"/>
<arg value="true"/>
<arg value="-autoNameResolution"/>
<arg value="-wsdlLocation"/>
<arg value="${wsdl.url}"/>
<arg value="${wsdl.url}"/>
<classpath>
<path refid="cxf.classpath"/>
</classpath>
</java>
</target>
出站邮件日志
URL wsdlURL = Service.WSDL_LOCATION;
if (args.length > 0 && args[0] != null && !"".equals(args[0])) {
File wsdlFile = new File(args[0]);
try {
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
Service service = new Service();
ReqServicePortType port = service.getReqServicePort();
String endpoint = "http://server:port/<path to end point>";
BindingProvider provider = (BindingProvider) port;
provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
provider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "username");
provider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "password");
provider.getRequestContext().put("schema-validation-enabled", "true");
Client client = ClientProxy.getClient(port);
LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
loggingInInterceptor.setPrettyLogging(true);
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
loggingOutInterceptor.setPrettyLogging(true);
client.getInInterceptors().add(loggingInInterceptor);
client.getOutInterceptors().add(loggingOutInterceptor);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(36000);
httpClientPolicy.setAllowChunking(false);
http.setClient(httpClientPolicy);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
CustomHeader header= new CustomHeader();
//setting header value....
header.setTimestamp(sdf.format(new Date()));
Holder<CustomHeader> headers = new Holder<CustomHeader>(header);
ReqDoc reqDoc = new ReqDoc();
//setting reqDoc value...
reqDoc.setTranxId("5");
ProcessReq req = new ProcessReq();
req.setInput(reqDoc);
ProcessReqResponse response = port.processReq(req, headers);
RespDoc respDoc = null;
if(response != null){
respDoc = response.getOutput();
}
String msgCode = "";
String msgDesc = "";
if(respDoc != null){
msgCode = respDoc.getMsgCode();
msgDesc = respDoc.getMsgDesc();
}
System.out.println("msgCode: " + msgCode);
System.out.println("msgDesc: " + msgDesc);
正如你所看到的那样,我尝试设置chuking到INFO: Outbound Message
--------------------------- ID: 1 Address: http://server:port/<path to service> Encoding: UTF-8 Http-Method: POST Content-Type: text/xml Headers: {Accept=[*/*], Authorization=[Basic 12341323232323=], SOAPAction=["Service_Binder_processReq"]} Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header>
<header xmlns:ns3="http://<my package>" xmlns:ns2="http://<my schema>" xmlns="http://<my schema>">
<timestamp>20150525115746</timestamp>
</header> </soap:Header> <soap:Body/> </soap:Envelope>
,但它仍然是相同的。
任何评论或想法都表示赞赏。感谢。
答案 0 :(得分:2)
发现当您在不引用CXF Lib jar文件的情况下运行生成的客户端类时会发生这种情况。将它们添加到类路径中后,将生成消息正文。
答案 1 :(得分:1)
在我的情况下,由于类路径上的不同版本的cxf jar,soap body是空的。我使用的是camel-cxf 2.5.3,它取决于cxf 3.0.6版。我在我的gradle脚本中错误地包含了cxf-rt-transports-http-jetty 3.1.1版本,该脚本添加了3.1.1 cxf-core并导致空肥皂体问题。通过将版本3.0.6用于cxf-rt-transports-http-jetty修复了问题,现在正确填充了正文。