gpt4 book ai didi

javax.xml.ws.WebServiceException : Undefined port type Java Struts SOAP WSDL

转载 作者:搜寻专家 更新时间:2023-10-31 19:47:48 25 4
gpt4 key购买 nike

好吧,我真的有一个奇怪的问题,我今天一直在谷歌和雅虎中寻找解决方案近 4 个小时。我拼命寻找解决方案。

public static String [] checkCardAccount(String cardNumber, String cardIssuer, String securityNumber){

URL url = null;
try {
url = new URL("http://localhost:8999/bankcard?wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
}

QName qname = new QName("http://server.bcard.soap.com/","BankCardImplService");

Service service = Service.create(url,qname);

BankCard bankcard = service.getPort(BankCard.class);

return bankcard.getCardClientData(cardNumber, cardIssuer);
}

上面的代码是我访问 SOAP 服务的客户端,它在独立的 java 应用程序中确实有效,但是当我将它嵌入到我的 Java Struts 应用程序时,它在下面显示以下错误

javax.xml.ws.WebServiceException: Undefined port type: {http://bankcard.api.com/}BankCard at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:349) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:355) at javax.xml.ws.Service.getPort(Service.java:161) at com.api.bankcard.BankCardClient.checkCardAccount(BankCardClient.java:25) at com.action.CardregAction.execute(CardregAction.java:18) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662)

现在我真的看到问题出在目标 namespace ,因为当我更改它时,错误更改为它表示有效服务是 {http://bankcard.api.com/}BankCard

我哪里错了?此代码可在 Java 应用程序上独立运行,但不能在我的 Java Struts Web 应用程序中运行

最佳答案

在实现类的@WebService注解中给出endpointIneterface,如果不给出端点接口(interface),则在使用getPort方法时必须提及完全限定的端口名称。

service.getPort("PortQName",BankCard.class);

关于javax.xml.ws.WebServiceException : Undefined port type Java Struts SOAP WSDL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13417454/

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