问题描述
- ****client call webservice error(have ws-policy)
-
问题是这样的:怎样编写client端代码调用一个webservice, 这个WS是deploy在weblogic上的,重点是做了ws-policy配置(需要用户名,密码认证),他们只提供给了我们WSDL。
我做了下面这些,可还是调用失败,并且错误信息不明确,哪为高手指点下小女子。不知到是否还需要别的配置, rampart ?
- 新建了一个java项目,导入Axis2 (1.6.2) jar包。
- 用WSDL2Java生成客户端代码(基于wsdl文件)
网上说WSDL2Java会自动把wsdl里的policy文件自动添加到生成的java文件里,参考:https://axis.apache.org/axis2/java/core/docs/WS_policy.html#client
xxxStub
xxxCallbackHandler - 用WSDL2Java生成客户端代码(基于wsdl文件)
- Client代码
// Create stub
xxxStub stub = new xxxStub();// Set userName, password
HttpTransportProperties.Authenticator basicAuthentication = new HttpTransportProperties.Authenticator();
basicAuthentication.setUsername("***");
basicAuthentication.setPassword("***");
stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, basicAuthentication);// Prepare input parameters
...// Set parameters
...// Invoke Services
GetReportResponse response = stub.getReport(parameters);// Get result
... = response.getGetReportResult(); - 错误信息:
org.apache.axis2.AxisFault: Unknown exception, internal system processing error.
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 ....xxxStub.getReportMetaData(xxxStub.java:200)
- 新建了一个java项目,导入Axis2 (1.6.2) jar包。
时间: 2024-12-04 22:02:25