我正在jboss 7中工作,並使用CXF框架構建Web服務客戶端。如果從服務器調用Webservice客戶端失敗:如果從Junit(本地)調用獲取調用成功
我寫了一個特定的webservice客戶端來調用遠程服務器中部署的webservice。
如果這個webservice客戶端是從Junit測試用例中調用的,那麼webservice調用成功,我們從服務器獲得有效的xml響應。
但是,如果同樣的Web服務客戶端與服務器(Web服務客戶端本身被部署爲Web應用程序)調用的話,它會拋出異常如下:
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文件中設置的bean。
下面是Web服務客戶端代碼:
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應用程序服務器之間的webservice客戶端調用之間的區別。
謝謝,羅伯託,我需要修改我的JRE設置。 – EpicVoyage