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

2

7

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)
Corticate answered 25/5, 2012 at 23:9 Comment(5)
You seem to be invoking service by using WSDL's address, not a real endpoint address.Ilocano
@GrzegorzGrzybek Actually, your comment is the answer!Orva
@GrzegorzGrzybek The endpoint url gives me, when put in browser <SOAP-ENV:Envelope xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>Sender</faultcode> <faultstring>Invalid XML</faultstring> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>Margay
still when I used this, i got this error "java.lang.RuntimeException: org.apache.axis2.AxisFault: Procedure 'login' not present" try { login(); } catch (AxisFault e) { throw new RuntimeException(e); }Margay
without web.xml and axis config I can't tell anything more than my first comment....Ilocano
L
6

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.

Lindon answered 21/6, 2013 at 15:11 Comment(0)
V
1

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.

Valvular answered 2/5, 2013 at 9:49 Comment(1)
usually its "soap12:address"Chronology

© 2022 - 2024 — McMap. All rights reserved.