gpt4 book ai didi

java - 如果从服务器 : Gets called successfully if invoked from Junit(locally) 调用 Web 服务客户端失败

转载 作者:可可西里 更新时间:2023-11-01 16:02:42 26 4
gpt4 key购买 nike

我在 jboss 7 中工作并使用 CXF 框架构建 web 服务客户端。

我编写了一个特定的网络服务客户端来调用部署在远程服务器上的网络服务。

如果这个 web 服务客户端是从 Junit 测试用例调用的,那么 web 服务调用是成功的,我们从服务器得到有效的 xml 响应。

但是如果从服务器调用相同的 web 服务客户端(web 服务客户端本身部署为 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 中获取的。

以下是 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 应用服务器的 Web 服务客户端调用之间的区别。

最佳答案

添加对cxf-rt-transports-http-jetty 的依赖为我解决了这个问题,正如建议的那样here .

关于java - 如果从服务器 : Gets called successfully if invoked from Junit(locally) 调用 Web 服务客户端失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20728188/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com