我正在使用 CXF 来帮助我调用某些 Web 服务。我能够让我的代码在本地运行,但是当我部署我的战争时,我遇到了问题。查看日志后,我相信 WAS CE 使用axis2 作为其Web 服务引擎。这是导致我的问题的原因吗?CXF 库不能在 WAS CE 服务器上运行吗?
编辑:这是我的代码。问题似乎与 x509 身份验证有关。我已经能够调用一个不同的 Web 服务,它只需要基本的抢先式身份验证而没有问题。
URL wsdlURL = new URL(endpoint);
/*WSOrganization ss = new WSOrganization(wsdlURL, SERVICE_NAME);
port = ss.getWSOrganizationSoap();*/
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress(endpoint);
factory.setServiceClass(WSSoap.class);
port = (WSSoap) factory.create();
Client client = ClientProxy.getClient(port);
Endpoint cxfEndpoint = client.getEndpoint();
Map<String,Object> outProps = new HashMap<String,Object>();
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
outProps.put(WSHandlerConstants.ACTION, "Signature");
outProps.put(WSHandlerConstants.USER, "alias");
outProps.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,
PWDCallbackHandler.class.getName());
outProps.put(WSHandlerConstants.SIG_PROP_FILE, "crypto.properties");
cxfEndpoint.getOutInterceptors().add(wssOut);
日志给了我这个错误:
javax.xml.ws.soap.SOAPFaultException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
at $Proxy96.findCode(Unknown Source)
... 6 more
Caused by:
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
at org.w3c.dom.DOMException.<init>(Unknown Source)
at org.apache.axiom.om.impl.dom.ParentNode.insertBefore(ParentNode.java:164)
at org.apache.axiom.om.impl.dom.NodeImpl.appendChild(NodeImpl.java:238)
at org.apache.axis2.saaj.SOAPPartImpl.appendChild(SOAPPartImpl.java:986)
at org.apache.cxf.staxutils.W3CDOMStreamWriter.setChild(W3CDOMStreamWriter.java:114)
at org.apache.cxf.staxutils.W3CDOMStreamWriter.newChild(W3CDOMStreamWriter.java:104)
at org.apache.cxf.staxutils.W3CDOMStreamWriter.writeStartElement(W3CDOMStreamWriter.java:132)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:122)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:81)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:61)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:519)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:449)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:352)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:304)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
... 7 more