WSDL Client Calling Failed

XuSen :

First time working on SOAP services. I need to call this web service. http://demomt.weblite.com.my/TS_Services/SubmissionsService.asmx?WSDL

Here are the 2 out of 11 of the stubs that i have generated using wsimport

I tried for the whole day, but I keep getting this error message. Why? I suspect because i did not pass in the authentication header correctly. But at the same time i'm wondering how come the generated stub does not comes with Authentication header as a method param? is that normal? Need help. I'm so confusing.

Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Server was unable to process request. ---> Object reference not set to an instance of an object. Please see the server log to find more detail regarding exact cause of the failure.

WebLITETSServicesSoap.java

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

@WebService(name = "WebLITE_TSServicesSoap", targetNamespace = "TransactionalSubmissionsSvcs")
@XmlSeeAlso({
    ObjectFactory.class
})
public interface WebLITETSServicesSoap {

    @WebMethod(operationName = "GetTemplateList", action = "TransactionalSubmissionsSvcs/GetTemplateList")
    @WebResult(name = "GetTemplateListResult", targetNamespace = "TransactionalSubmissionsSvcs")
    @RequestWrapper(localName = "GetTemplateList", targetNamespace = "TransactionalSubmissionsSvcs", className = "transactionalsubmissionssvcs.GetTemplateList")
    @ResponseWrapper(localName = "GetTemplateListResponse", targetNamespace = "TransactionalSubmissionsSvcs", className = "transactionalsubmissionssvcs.GetTemplateListResponse")
    public String getTemplateList();


    @WebMethod(operationName = "SendWithXML", action = "TransactionalSubmissionsSvcs/SendWithXML")
    @WebResult(name = "SendWithXMLResult", targetNamespace = "TransactionalSubmissionsSvcs")
    @RequestWrapper(localName = "SendWithXML", targetNamespace = "TransactionalSubmissionsSvcs", className = "transactionalsubmissionssvcs.SendWithXML")
    @ResponseWrapper(localName = "SendWithXMLResponse", targetNamespace = "TransactionalSubmissionsSvcs", className = "transactionalsubmissionssvcs.SendWithXMLResponse")
    public String sendWithXML(
        @WebParam(name = "xmldoc", targetNamespace = "TransactionalSubmissionsSvcs")
        SendWithXML.Xmldoc xmldoc);


    @WebMethod(operationName = "SendWithJSON", action = "TransactionalSubmissionsSvcs/SendWithJSON")
    @WebResult(name = "SendWithJSONResult", targetNamespace = "TransactionalSubmissionsSvcs")
    @RequestWrapper(localName = "SendWithJSON", targetNamespace = "TransactionalSubmissionsSvcs", className = "transactionalsubmissionssvcs.SendWithJSON")
    @ResponseWrapper(localName = "SendWithJSONResponse", targetNamespace = "TransactionalSubmissionsSvcs", className = "transactionalsubmissionssvcs.SendWithJSONResponse")
    public String sendWithJSON(
        @WebParam(name = "emaillist", targetNamespace = "TransactionalSubmissionsSvcs")
        String emaillist,
        @WebParam(name = "params", targetNamespace = "TransactionalSubmissionsSvcs")
        String params);

}

WebLITETSServices.java

import javax.xml.namespace.QName;
import javax.xml.ws.*;
import java.net.MalformedURLException;
import java.net.URL;


@WebServiceClient(name = "WebLITE_TSServices", targetNamespace = "TransactionalSubmissionsSvcs", wsdlLocation = "http://demomt.weblite.com.my/TS_Services/SubmissionsService.asmx?WSDL")
public class WebLITETSServices
    extends Service
{

    private final static URL WEBLITETSSERVICES_WSDL_LOCATION;
    private final static WebServiceException WEBLITETSSERVICES_EXCEPTION;
    private final static QName WEBLITETSSERVICES_QNAME = new QName("TransactionalSubmissionsSvcs", "WebLITE_TSServices");

    static {
        URL url = null;
        WebServiceException e = null;
        try {
            url = new URL("http://demomt.weblite.com.my/TS_Services/SubmissionsService.asmx?WSDL");
        } catch (MalformedURLException ex) {
            e = new WebServiceException(ex);
        }
        WEBLITETSSERVICES_WSDL_LOCATION = url;
        WEBLITETSSERVICES_EXCEPTION = e;
    }

    public WebLITETSServices() {
        super(__getWsdlLocation(), WEBLITETSSERVICES_QNAME);
    }

    public WebLITETSServices(WebServiceFeature... features) {
        super(__getWsdlLocation(), WEBLITETSSERVICES_QNAME, features);
    }

    public WebLITETSServices(URL wsdlLocation) {
        super(wsdlLocation, WEBLITETSSERVICES_QNAME);
    }

    public WebLITETSServices(URL wsdlLocation, WebServiceFeature... features) {
        super(wsdlLocation, WEBLITETSSERVICES_QNAME, features);
    }

    public WebLITETSServices(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public WebLITETSServices(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
        super(wsdlLocation, serviceName, features);
    }

    @WebEndpoint(name = "WebLITE_TSServicesSoap")
    public WebLITETSServicesSoap getWebLITETSServicesSoap() {
        return super.getPort(new QName("TransactionalSubmissionsSvcs", "WebLITE_TSServicesSoap"), WebLITETSServicesSoap.class);
    }

    @WebEndpoint(name = "WebLITE_TSServicesSoap")
    public WebLITETSServicesSoap getWebLITETSServicesSoap(WebServiceFeature... features) {
        return super.getPort(new QName("TransactionalSubmissionsSvcs", "WebLITE_TSServicesSoap"), WebLITETSServicesSoap.class, features);
    }

    private static URL __getWsdlLocation() {
        if (WEBLITETSSERVICES_EXCEPTION!= null) {
            throw WEBLITETSSERVICES_EXCEPTION;
        }
        return WEBLITETSSERVICES_WSDL_LOCATION;
    }

}

I tried running with TestApplication

public class TestApplication {

    public static void main(String[] args) throws MalformedURLException {
        MailAdapterApplication adapterApplication = new MailAdapterApplication();
        adapterApplication.run();
    }

    public void run() throws MalformedURLException {

    WebLITETSServices services = new WebLITETSServices();
    WebLITETSServicesSoap servicesSoap = services.getPort(WebLITETSServicesSoap.class);
    Map<String, Object> req_ctx =((BindingProvider)servicesSoap).getRequestContext();
    Map<String, List<String>> headers = new HashMap<>();
    headers.put("Username",Collections.singletonList("[email protected]"));
    headers.put("Password", Collections.singletonList("P@ssW0rd32!"));
    headers.put("APIKey", Collections.singletonList("QdrLKxog"));

    req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
    System.out.println(servicesSoap.getTemplateList());

    }

}
gusto2 :

Client received SOAP Fault from server: Server was unable to process request.
Object reference not set to an instance of an object.
I keep getting this error message. Why?

Indeed you did call the service, but the server returned an error code with error message, where the returned payload has no mapping to any expected return type or soap fault exception. There is no more information in the in the text you've provided.

It would be really usefull to check the response status code and payload which was really returned. How to log the respone payload depends on the webservice library you use (cxf, axis2, ??)

I suspect because i did not pass in the authentication header correctly.

You should confirm that suspission, from the information provided it is not possible to tell. Though if you did not provide any authentication information, it is very possible

But at the same time i'm wondering how come the generated stub does not comes with Authentication header as a method param? is that normal? Need help. I'm so confusing.

I assume under the "Authentication header" you mean AuthHeader header. You may need to enable header generation when invoking the wsimport, as well depends in th framework used. When using wsimport from the default JDK, try to use -XadditionalHeaders parameter

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=159328&siteId=1