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


SOAP Service: I have a sample request file XML but getting confused about the format

我正在集成一个运行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需要"信封和正文",以便请求符合

<?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>

现在我对给我的示例请求文件感到困惑。我尝试制作以下SOAP请求,并在请求头中添加SOAPAction,但无济于事

<?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>
谁能告诉我我错过了什么?

不确定您是否仍然面临这个问题。它缺少请求元素以及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>