请帮助:我试图从SOAPUI调用WebService,我注意到该服务需要用户名和密码,我通过请求参数提供.我注意到原始
XML包含添加到SOAPHeader的用户/密码片段.摘录如下:
testusertestpassword&RYadQak91mr7dB+5hyt8yw==2011-10-24T20:13:43.039Z
现在我想通过添加用户/密码详细信息来实现同样的目的,如下面的代码所示:代码片段是:
org.tempuri.myService.MyServiceStub stub = new org.tempuri.myService.MyServiceStub();
ServiceClient sc = stub._getServiceClient();
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername("testuser");
auth.setPassword("password$");
sc.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,auth);
org.tempuri.myService.MyServiceDocument myService4 = (org.tempuri.myService.MyServiceDocument)getTestObject(org.tempuri.myService.MyServiceDocument.class);
MyService lval = MyService4.addNewMyService();
MyServiceParameters lvParams = lval.addNewParameters();
lvParams.setA("24");
lvParams.setB("10");
lval.setParameters(lvParams);
myService4.setMyService(lval);
但我得到了Axis故障异常,需要帮助我正在用上面的代码做的错误.轴故障异常详细信息:
org.apache.axis2.AxisFault: Exception occurred while executing service 'MyService'.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.tempuri.myService.MyServiceStub.myService(MyServiceStub.java:182)
at org.tempuri.myService.MyServiceTest.main(MyServiceTest.java:55)
MyServiceResponseDocument lvdoc = stub.myService(myService4);