VPR
VPR

Reputation: 71

org.apache.axis2.AxisFault: First Element must contain the local name, Envelope , but found definitions

Requests works fine in my local environment and it doesn't work on the deployed environment . Requests were tried from various clients including soapui. Code is deployed on WAS

Axis2

org.apache.axis2.AxisFault: First Element must contain the local name, Envelope , but found definitions
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
    at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:123)
    at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)
Caused by: org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found definitions
    at java.lang.Throwable.<init>(Throwable.java:67)

Upvotes: 7

Views: 40885

Answers (2)

etech
etech

Reputation: 2761

This is an issue with the server not returning the expected xml response format. This can be caused by using an incorrect service endpoint URL.

To fix, ensure that the URL used in your Axis code matches the URL for the endpoint in the WSDL that your code is based on.

Location in WSDL:

    <service name="ServiceName">
      <port name="PortName" binding="typens:PortNameBinding">
        <soap:address location="http://yourdomain.com/api/soap/"/>
      </port>
    </service>

The corresponding location in code, is typically found in the ServiceNameStub class at two locations:

    /**
     * Default Constructor
     */
    public ServiceNameStub(
            org.apache.axis2.context.ConfigurationContext configurationContext)
            throws org.apache.axis2.AxisFault {

        this(configurationContext,
                "http://yourdomain.com/api/soap/");

    }

    /**
     * Default Constructor
     */
    public ServiceNameStub() throws org.apache.axis2.AxisFault {

        this("http://yourdomain.com/api/soap/");

    }

Just ensure that those two URLs match the URL found at soap:address for the service port in your WSDL file.

Upvotes: 6

Nash
Nash

Reputation: 131

Yes, I had the same issue and resolved it by changing the WSDL with endpoint URL. I updated how to find the endpoint URL below:

a) open the WSDL file in web browser. b) locate "soap:address" under "wsdl:port" tag. c) copy and paste the URL next to location in your client code.

That's it.

Upvotes: 1

Related Questions