java soap协议控制路由器,尝试通过Java设置用户名和密码向SOAP WsdlRequest提交请求时的ClientProtocolException...

我的目的是使用给定的wsdl URL创建一个Soap UI项目,保存它并通过

Java方法发送所有请求.我收到org.apache.http.client.ClientProtocolException …..由以下原因引起:org.apache.http.ProtocolException:当我尝试通过设置操作的用户名和密码来提交请求时,Content-Length标头已经出现错误.找到我的Java方法来发送请求.

public void runSoap() throws Exception

{

String projectFile = "SoapUIProjects/TestProjectA-soapui-project.xml";

SoapUI.setSoapUICore(new StandaloneSoapUICore(true));

WsdlProject project = new WsdlProject(projectFile);

int c = project.getInterfaceCount();

System.out.println("The interface count ="+c);

for(int i=0;i

{

WsdlInterface wsdl = (WsdlInterface) project.getInterfaceAt(i);

String soapVersion = wsdl.getSoapVersion().toString();

int opc = wsdl.getOperationCount();

String result="";

for(int j=0;j

{

WsdlOperation op = wsdl.getOperationAt(j);

String opName = op.getName();

System.out.println("OPERATION:"+opName);

WsdlRequest req = op.getRequestByName("Req_"+soapVersion+"_"+opName);

//Assigning correct u/p to an operation: Generate

if(opName.equals("Generate"))

{

System.out.println("The operation is Generate.");

req.setUsername("u1");//Setting username

req.setPassword("u1");//Setting password

}

WsdlSubmitContext wsdlSubmitContext = new WsdlSubmitContext(req);

WsdlSubmit> submit = (WsdlSubmit>) req.submit(wsdlSubmitContext, false);

Response response = submit.getResponse();

result = response.getContentAsString();

System.out.println("The result ="+result);

}

}

}

另请参阅附图.有人可以告诉我哪里出错了以及如何解决这个问题?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值