今天我根据其他公司提供的WebService接口的wsdl文件生成客户端调用代码时,遇到两个问题 1.对方的wsdl文件中包含了自己定制的描述文件,这些个文件需要从wsdl文档中的地址去访问,由于
今天我根据其他公司提供的WebService接口的wsdl文件生成客户端调用代码时,遇到两个问题
1.对方的wsdl文件中包含了自己定制的描述文件,这些个文件需要从wsdl文档中的地址去访问,由于我这边无法访问对方的内部网络,导致连接失败,无法生成客户端,最后是在对方公司内网中的电脑上生成的客户端调用代码
2.对方设置了WebService接口访问授权,需要在wsimport上加上-Xauthfile命令参数,该参数指定了授权用户密码所在的文件路径,文件中的格式如下
http://username:pwd@host:port/serverpath?wsdl
然后以如下命令生成客户端调用代码
wsimport -keep -p com.mypackage.client -Xauthfile D:\Xauthfile.txt http://host:port/serverpath?wsdl
没有添加-Xauthfile命令参数时,报错信息如下:
[ERROR] Server returned HTTP response code: 401 for URL:http://host:port/serverpath?wsdl,
"http://host:port/serverpath?wsdl " needs authorization,please provide
authorization file with read access at C:\Users\Administrator\.metro\auth or
use -Xauthfile to http[s]://user:password@host:port//<url-path>
添加-Xauthfile命令参数后,如有以下报错信息,可能是该服务暂时不能访问,或者用户名密码错误:
[ERROR] Server redirected too many times (20), "http://host:port/serverpath?wsdl"
needs authorization, please provide authorization file with read access at C:\Users\Administrator\.metro\auth
or use -Xauthfile to give the authorization file and on each line provide authorization information
using this format :http[s]://user:password@host:port//<url-path>