当前位置:编程学习 > JAVA >>

Axis2(启用rampart)客户端调用时 报错误

Tomcat+Axis2(启用Rampart)
webservice发布成功了,但是https调用的时候出了些问题
我的调用中
axis2的lib,rampart的modules和lib都加入了,jks也没问题
这个错误在网上查了下,我没有找到解决方案,
各位朋友帮个忙

log4j:WARN No appenders could be found for logger (org.apache.axis2.deployment.FileSystemConfigurator).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.apache.axis2.AxisFault: java.lang.NullPointerException
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 tutorial.rampart.client.WS_rampart2Stub.add(WS_rampart2Stub.java:223)
at tutorial.rampart.client.SecureServiceCGClient.main(SecureServiceCGClient.java:35)
--------------------编程问答-------------------- 客户端源码

package tutorial.rampart.client;

import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.HTTPConstants;

public class SecureServiceCGClient {

// -uri http://localhost:8080/axis2/services/SecureService?wsdl -p tutorial.rampart.client -uw

public static void main(String[] args) throws Exception {

     System.setProperty("javax.net.ssl.trustStore", "keys/.keystore");
     System.setProperty("javax.net.ssl.trustStorePassword", "xxxxx");
    
     //To be able to load the client configuration from axis2.xml
    
     ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("rampart", null);
WS_rampart2Stub stub = new WS_rampart2Stub(ctx,"https://xxx.xxx.xxx.xxx/axis2/services/WS_rampart2");

ServiceClient sc = stub._getServiceClient();
sc.engageModule("rampart");

Options options = sc.getOptions();
options.setUserName("axis2");
options.setPassword("rampart");
// options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 0);
// sc.setOptions(options);

int a = 3;
int b = 4;
int result = stub.add(a, b);

int x = 1;
int y = 100;
int sumresult = stub.sumMtoN(x, y);

System.out.println(a + " + " + b + " = " + result);
System.out.println(x + " ~ " + y + " = " + sumresult);
System.out.println(stub.helloWorld());

}

}
--------------------编程问答-------------------- 我从services.xml中去掉这部分断言

<sp:SignedSupportingTokens><wsp:Policy><sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"/></wsp:Policy></sp:SignedSupportingTokens>

就能通过访问了,但是在web地址栏中也能计算了,不符合要求
补充:Java ,  Web 开发
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,