WebService客户端生成代码错误解决方案

1.在浏览器中打开webservice url,保存wsdl文件,如ContentService.xml 
2.通过cxf命令“wsdl2java –d E:/file –frontend jaxws21 –client C:\ ContentService.xml”生成客户端代码 
3.若报WSDLToJava Error: Thrown by JAXB : undefined simple or complex type 'soap-enc:Array' , 
则需要在生成的文件中找到 
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />, 
在浏览器中打开http://schemas.xmlsoap.org/soap/encoding/, 
保存文件soap-encoding.xsd, 
然后修改成<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="soap-encoding.xsd"/>, 

再运行上面的命令即可。 

4.如果需要NTLM认证,则需在代码中加入如下的代码: 

Java代码   收藏代码
  1. Client client = ClientProxy.getClient(port);  
  2.   
  3. HTTPConduit http = (HTTPConduit) client.getConduit();  
  4.   
  5. HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();   
  6.   
  7. httpClientPolicy.setConnectionTimeout(36000);  
  8.   
  9. httpClientPolicy.setAllowChunking(false);  
  10.   
  11. http.setClient(httpClientPolicy);  
  12.   
  13. http.getAuthorization().setAuthorizationType("NTLM");   
  14.   
  15. http.getAuthorization().setUserName("xxxx");  
  16.   
  17. http.getAuthorization().setPassword("xxxxx");  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值