Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 569
Netorica Avatar asked Nov 16 '12 13:11

Netorica


2 Answers

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

like image 145
anil kumar Avatar answered Nov 04 '22 23:11

anil kumar


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);
like image 26
MrCelticFox Avatar answered Nov 05 '22 00:11

MrCelticFox