0

I created a Java Web Service based on an existing 3rd party .NET Web Service. This is my web service interface:

package externalqueryadapter.service._01.responsereceiver;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
import org.datacontract.schemas._2004._07.commonservices_externalqueryadapter.ExternalResponse;

@WebService(name = "ResponseReceiver", targetNamespace = "http://Service.ExternalQueryAdapter/01/ResponseReceiver")
@XmlSeeAlso({
    externalqueryadapter.service._01.responsereceiver.ObjectFactory.class,
    org.datacontract.schemas._2004._07.commonservices_externalqueryadapter_contract.ObjectFactory.class
})
public interface ResponseReceiver {

    @WebMethod(operationName = "ReceiveResponse")
    @RequestWrapper(localName = "ReceiveResponse", targetNamespace = "http://Service.ExternalQueryAdapter/01/ResponseReceiver", className = "externalqueryadapter.service._01.responsereceiver.ReceiveResponse")
    @ResponseWrapper(localName = "ReceiveResponseResponse", targetNamespace = "http://Service.ExternalQueryAdapter/01/ResponseReceiver", className = "externalqueryadapter.service._01.responsereceiver.ReceiveResponseResponse")
    @Action(input = "http://Service.ExternalQueryAdapter/01/ResponseReceiver/ResponseReceiver/ReceiveResponseRequest", output = "http://Service.ExternalQueryAdapter/01/ResponseReceiver/ResponseReceiver/ReceiveResponseResponse")
    public void receiveResponse(
        @WebParam(name = "response", targetNamespace = "http://schemas.datacontract.org/2004/07/CommonServices.ExternalQueryAdapter.Contract")
        ExternalResponse response);
}

And my ExternalResponse class

package org.datacontract.schemas._2004._07.commonservices_externalqueryadapter_contract;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "externalResponse", propOrder = {
    "requestTime",
    "userID"
})
public class ExternalResponse {

    @XmlSchemaType(name = "dateTime")
    protected XMLGregorianCalendar requestTime;
    protected String userID;

    public XMLGregorianCalendar getRequestTime() {
        return requestTime;
    }

    public void setRequestTime(XMLGregorianCalendar value) {
        this.requestTime = value;
    }

    public String getUserID() {
        return userID;
    }

    public void setUserID(String value) {
        this.userID = value;
    }
}

I successfully receive SOAP messages from the Java WebService client like this:

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <ReceiveResponse
            xmlns="http://Service.ExternalQueryAdapter/01/ResponseReceiver">
            <response
                xmlns="">
                <RequestTime>2013-01-30T20:00:00.000Z</RequestTime>
                <userID>olololo</userID>
            </response>
        </ReceiveResponse>
    </soapenv:Body>
</soapenv:Envelope>

But if the SOAP message contains a namespace for response parameter, (it's a message from a 3rd party webService client (I think a .NET client)) my Java WebService receives null in the ExternalResponse response.

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <ReceiveResponse
            xmlns="http://Service.ExternalQueryAdapter/01/ResponseReceiver">
            <response
                xmlns="http://schemas.datacontract.org/2004/07/CommonServices.ExternalQueryAdapter.Contract">
                <RequestTime>2013-01-30T20:00:00.000Z</RequestTime>
                <userID>olololo</userID>
            </response>
        </ReceiveResponse>
    </soapenv:Body>
</soapenv:Envelope>

package-info.java:

@javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.datacontract.org/2004/07/CommonServices.ExternalQueryAdapter.Contract", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.datacontract.schemas._2004._07.CommonServices_ExternalQueryAdapter_Contract;

What is wrong in my Java Web Service?

1 Answer 1

1

Could you have failed to include the package-info.class in your archive?

Since the not-working case (including the TNS) matches the JAX-WS @WebParam, I wonder if you generated JAXBs with elementFormDefault="qualified" (you can usually see this in package-info.java) but maybe failed to zip them up (or load them into the JAXBContext), which might default elementFormDefault to unqualified

If that doesn't help maybe it would help to paste the WSDL/XSD and explain how you're producing the JAX-WS and JAXB annotated classes. With wsimport?

Sign up to request clarification or add additional context in comments.

2 Comments

I added the package-info.java to question. No, the package-info.class included in my war archive. I didn't generate classes from WSDL/XSD schema, because i have not access to 3rd party WebService WSDL/XSD. I created Web Service via NetBeans -> New -> WebService and added manually the ExternalResponse class
Maybe post your WSDL/XSD ? Not sure I personally will be able to help but maybe someone else will.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.