我正在使用jboss 7并使用CXF框架构建webservice客户端。
我编写了一个特定的Web服务客户端来调用部署在远程服务器中的Web服务。
如果从Junit测试用例调用此Web服务客户端,则webservice调用成功,我们从服务器获得有效的xml响应。
但是如果从服务器调用相同的webservice客户端(webservice客户端本身被部署为webapp),那么它会抛出异常:
Caused by: javax.xml.ws.soap.SOAPFaultException: Could not find conduit initiator for address:
http://10.100.20.101/metavante1/ConnectwareWS/DPAcctTxnInqWSV1
and transport: http://schemas.xmlsoap.org/soap/http
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
at sun.proxy.$Proxy137.dpAcctTxnInq(Unknown Source)
at webservice.client.hsa.MetavanteHSAPort.getAccountDetails(MetavanteHSAPort.java:1785) [webserviceclient.jar:]
... 34 more
Caused by: java.lang.RuntimeException: Could not find conduit initiator for address:
http://10.100.20.101/metavante1/ConnectwareWS/DPAcctTxnInqWSV1
and transport: http://schemas.xmlsoap.org/soap/http
at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:225)
at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:110)
at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63)
at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:850)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:525)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
... 36 more
在这种情况下,URL http://10.100.20.101/metavante1/ConnectwareWS/DPAcctTxnInqWSV1
是从一个在XML文件中设置的spring bean中提取的。
以下是webservice客户端的代码:
public HSAAccountDetailsBn getAccountDetails(String bankAccNum)
throws ServiceException
{
HSAAccountDetailsBn detailsBn = new HSAAccountDetailsBn();
try{
URL wsdl = WebServiceClientUtil.getResourceAsURL("wsdl/clients/Metavante/DPAcctTxnInqWSV1.wsdl");
MtvnCWDPAcctTxnInqWSV1 service = new MtvnCWDPAcctTxnInqWSV1(wsdl);
MtvnCWDPAcctTxnInqWSV1Interface port = service
.getMtvnCWDPAcctTxnInqWSV1Port();
BindingProvider provider = (BindingProvider) port;
provider.getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
this.getServiceEndpointAcctTxnInq()
);
System.out.println("Invoking dpAcctTxnInq...");
webservice.client.metavante.deposit.acctTrxnEnquiry.ObjectFactory obj = new webservice.client.metavante.deposit.acctTrxnEnquiry.ObjectFactory();
DPAcctTxnInqMtvnSvcReq dpAcctTxnInqReq = obj
.createDPAcctTxnInqMtvnSvcReq();
dpAcctTxnInqReq.setMtvnSvcVer("1.0");
dpAcctTxnInqReq.setMsgUUID("11111111-1111-1111-1111-111111111114");
DPAcctTxnInqMtvnSvcReq.PrcsParms prcsParms = obj
.createDPAcctTxnInqMtvnSvcReqPrcsParms();
prcsParms.setSrcID("GJL747");
prcsParms.setTestInd("Y");
dpAcctTxnInqReq.setPrcsParms(prcsParms);
DPAcctTxnInqMtvnSvcReq.Svc svc = obj
.createDPAcctTxnInqMtvnSvcReqSvc();
DPAcctTxnInqMtvnSvcReq.Svc.SvcParms svcParms = obj
.createDPAcctTxnInqMtvnSvcReqSvcSvcParms();
svcParms.setApplID("DP");
svcParms.setRoutingID(getRoutingId());
svcParms.setRqstUUID("11111111-1111-1111-1111-111111111114");
svcParms.setSvcID("DPAcctTxnInq");
svcParms.setSvcVer("1.0");
svc.setSvcParms(svcParms);
DPAcctTxnInqMtvnSvcReq.Svc.Security security = obj
.createDPAcctTxnInqMtvnSvcReqSvcSecurity();
DPAcctTxnInqMtvnSvcReq.Svc.Security.BasicAuth basicAuth = obj
.createDPAcctTxnInqMtvnSvcReqSvcSecurityBasicAuth();
basicAuth.setUsrID(this.getUsernameDeposit());
basicAuth.setPwd(this.getPasswordDeposit());
security.setBasicAuth(basicAuth);
svc.setSecurity(security);
DPAcctTxnInqMtvnSvcReq.Svc.MsgData msgData = obj
.createDPAcctTxnInqMtvnSvcReqSvcMsgData();
DPAcctTxnInqReqData dpAcctInqReqData = obj
.createDPAcctTxnInqReqData();
if (!CommonSupportUtil.isNull(bankAccNum))
{
dpAcctInqReqData.setE20007(bankAccNum); // account number
}
dpAcctInqReqData.setE310129("N");
dpAcctInqReqData.setE310130("N");
dpAcctInqReqData.setE310128("Y");
msgData.setDPAcctTxnInqReqData(dpAcctInqReqData);
svc.setMsgData(msgData);
dpAcctTxnInqReq.getSvc().add(svc);
DPAcctTxnInqMtvnSvcRes dpAcctTxnInqRes = port
.dpAcctTxnInq(dpAcctTxnInqReq);
List<DPAcctTxnInqMtvnSvcRes.Svc> resSvclist = dpAcctTxnInqRes.getSvc();
DPAcctTxnInqMtvnSvcRes.Svc resSvc = resSvclist.get(0);
DPAcctTxnInqResData resData = resSvc.getMsgData()
.getDPAcctTxnInqResData();
String returnStatus = dpAcctTxnInqRes.getErrCde();
if (returnStatus.equalsIgnoreCase("0"))
{
detailsBn.setAccruedInterest(new Double(resData.getE20638()));
detailsBn.setAvailableBalance(new Double(resData.getE21667()));
detailsBn.setClosingBalance(new Double(resData.getE20167()));
detailsBn.setCurrentBalance(new Double(resData.getE21661()));
detailsBn.setLedgerBalance(new Double(resData.getE21632()));
String openIndicator = resData.getE20276();
detailsBn.setOpenIndicator(openIndicator);
String dormantIndicator = resData.getE20277();
detailsBn.setDormantIndicator(dormantIndicator);
}
else
{
throw new ServiceException("Could not access Metavante Deposit system ");
}
}
catch (SOAPFaultException e) {
throw new ServiceException(
"Vendor is intercepting the request but it is not returning the data. "
+ "This can mean that either they are not servicing request at this moment "
+ "at all or they are unable to service this request.",
e);
}
return detailsBn;
}//Method ends
我在这些问题上看了一些以前的帖子,但没有一个能正确解决我的问题。
我无法弄清楚Junit与jboss应用服务器之间的Web服务客户端调用之间的区别。
答案 0 :(得分:9)
根据here建议,添加对cxf-rt-transports-http-jetty
的依赖为我解决了这个问题。
答案 1 :(得分:1)
可能JUnit使用Eclipse的嵌入式JRE,而您的应用程序可能使用系统中安装的特定JRE。检查您是否使用相同的JRE来执行应用程序和JUnit测试用例。 然后,我在我的项目中遇到了同样的异常,在我的情况下问题是我在配置文件中的“...”中编写了Web服务URL。 希望能帮助到你, 罗伯特