org.apache.axis2.AxisFault:第一个元素必须包含本地名称 Envelope ,但找到的定义



>请求在我的本地环境中工作正常,但在部署的环境中不起作用。尝试了来自各种客户端的请求,包括 soapui。代码部署在 WAS 上

轴2

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)

这是服务器未返回预期的 xml 响应格式的问题。这可能是由于使用了不正确的服务终结点 URL 导致的。

要解决此问题,请确保安讯士代码中使用的 URL 与代码所基于的 WSDL 中端点的 URL 匹配。

在WSDL中的位置:

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

代码中的相应位置通常在 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/");
    }

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

是的,我遇到了同样的问题,并通过使用端点 URL 更改 WSDL 来解决它。我更新了如何在下面查找终结点 URL:

a) 在 Web 浏览器中打开 WSDL 文件。b) 在"WSDL:端口"标签下找到"SOAP:地址"。c) 复制并粘贴客户端代码中位置旁边的 URL。

就是这样。

最新更新