好的,我真的有一个奇怪的问题,我今天在 google 和 yahoo 中寻找解决方案将近 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:未定义的端口类型:com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:349) com 上的 {http://bankcard.api.com/}BankCard .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) 在 org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) 在 org.apache.struts 的 com.action.CardregAction.execute(CardregAction.java:18)。 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) 在 org.org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) 在 org.apache.struts.chain.ComposableRequestProcessor 的 apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)。 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) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 在 org.apache.catalina.valves.ErrorReportValve 的 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) .invoke(ErrorReportValve.java:102) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) 在 org. org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) 在 org.apache.tomcat.util.net.JIoEndpoint$ 的 apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) Worker.run(JIoEndpoint.java:489) 在 java.lang.Thread.run(Thread.java:662)apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:109) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) 在 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) 在 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 )apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:109) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) 在 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) 在 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 )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 (线程.java:662)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 (线程.java:662)第489章)第489章)
现在我真的看到问题出在目标命名空间上,因为当我更改它时,错误更改为它表示有效服务是{http://bankcard.api.com/}BankCard
我哪里出错了?此代码可在 Java 应用程序上独立运行,但不能在我的 Java Struts Web 应用程序中运行