org.apache.axis2.AxisFault:First Element必须包含本地名称Envelope,但找到了定义

VPR*_*VPR 7 websphere axis2 web-services

请求在我的本地环境中正常工作,并且在部署的环境中不起作用.来自包括soapui在内的各种客户尝试了请求.代码部署在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)
Run Code Online (Sandbox Code Playgroud)

ete*_*ech 6

这是服务器未返回预期的xml响应格式的问题.这可能是由使用不正确的服务端点URL引起的.

要进行修复,请确保Axis代码中使用的URL与代码所基于的WSDL中的端点的URL相匹配.

WSDL中的位置:

    <service name="ServiceName">
      <port name="PortName" binding="typens:PortNameBinding">
        <soap:address location="http://yourdomain.com/api/soap/"/>
      </port>
    </service>
Run Code Online (Sandbox Code Playgroud)

代码中的相应位置通常ServiceNameStub位于两个位置的类中:

    /**
     * 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/");

    }
Run Code Online (Sandbox Code Playgroud)

只需确保这两个URL与在WSDL文件中的服务端口的soap:address处找到的URL匹配.


Nas*_*ash 1

是的,我遇到了同样的问题,并通过更改带有端点 URL 的 WSDL 解决了该问题。我更新了如何查找端点 URL:

a) 在 Web 浏览器中打开 WSDL 文件。b) 在“wsdl:port”标签下找到“soap:address”。c) 复制并粘贴客户端代码中位置旁边的 URL。

就是这样。