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

2

5

ok I have really a strange problem that I keep looking for solution in google and yahoo for almost 4 hours today. And I desperately looking for a solution.

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);
    }

the above code is my client for accessing the SOAP service, it really works in a standalone java application but when I embed it to my Java Struts application it says the following error below

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)

Now I really see that the problem is the target namespace because as I change it the error changes to that it says that the valid services is {http://bankcard.api.com/}BankCard

where I went wrong? this code works on standalone on Java Application but not in my Java Struts web app

Peshitta answered 16/11, 2012 at 13:20 Comment(0)
G
6

give endpointIneterface in @WebService annotation in the implementation class, if you dont give endpoint interface, you have to mention fully qualified port name while using getPort method.

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

Genoa answered 23/4, 2013 at 18:7 Comment(1)
@anil kumar, could you please show an example how to mention fully qualified port name?Backandforth
J
1

You need to annotate the BankCardImpl class with @WebService(name="BankCard")
You can then use service.getPort(BankCard.class);

OR

If you just annotate it with @WebService or have given it another name, then you will need to provide more information to the getPort() method:

replace

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

with

QName port_name = new QName("http://server.bcard.soap.com/","BankCardImplPort");
BankCard bankcard = service.getPort(port_name, BankCard.class);
Jugal answered 9/10, 2016 at 14:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.