SOAP服务:我有一个示例请求文件XML,但对格式感到困惑

时间:2014-07-08 17:01:12

标签: php xml web-services soap

我正致力于集成到运行Apache Axis的远程服务。我收到了一个示例请求文件,如下所示

<?xml version="1.0" encoding="UTF-8"?>
<request xmlns="http://api.somedomain.com/openSession" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="openSession.xsd">
    <session key="xabc123092"/>
    <user name="admin" password="secret"/>
</request>

我知道SOAP需要&#34;信封和身体&#34;这样请求符合

<?xml version="1.0" encoding="UTF-8"?>
<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>
       ....
    </soapenv:Body>
</soapenv:Envelope>

现在我对提供给我的示例请求文件感到困惑。我试图在请求标头中使用一些SOAPAction来制作以下SOAP请求,但无济于事

<?xml version="1.0" encoding="UTF-8"?>
<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>
       <soapenv:openSession>
         <session key="xabc123092"/>
         <user name="admin" password="secret"/>
      </soapenv:openSession>
    </soapenv:Body>
</soapenv:Envelope>

以上给出了以下内容

<?xml version="1.0" encoding="UTF-8"?>
<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>
        <soapenv:Fault>
            <faultcode>soapenv:Server.userException</faultcode>
            <faultstring>org.xml.sax.SAXException: operation description is missing parameter description!</faultstring>
            <detail>
                <ns1:hostname 
                    xmlns:ns1="http://xml.apache.org/axis/">api.somedomain.com
                </ns1:hostname>
            </detail>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

有人能告诉我我在这里失踪了吗?

1 个答案:

答案 0 :(得分:1)

不确定您是否仍然面临此问题。它缺少请求元素以及soap请求中的命名空间。请尝试以下:

<?xml version="1.0" encoding="UTF-8"?>
<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>
        <request xmlns="http://api.somedomain.com/openSession" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="openSession.xsd">
            <session key="xabc123092"/>
            <user name="admin" password="secret"/>
        </request>
    </soapenv:Body>
</soapenv:Envelope>