为什么在尝试使用 Soap Web 服务时 SoapClient::__getLastRequest() 中的参数是 empty/broken?

Why is a parameter empty/broken in SoapClient::__getLastRequest() when attempting to use a Soap web service?

我们正在尝试调用由 https://demo2.mvrs.com/AdrConnect/AdrConnectWebService.svc?singlewsdl 的 wsdl 定义的函数 OrderInteractive()。它有两个参数,一个包含登录信息的通信块,以及一个包含数据的订单块。我知道登录信息是正确的,我们正在从该服务获得响应,但它给我们默认的 "unknown error has occurred" 消息。检查 __getLastRequest() 的结果时,我们得到:

<ns1:OrderInteractive>
    <ns1:inCommunications>
        <Communications>
            <Host>Online</Host>
            <Account>xxxxx</Account>
            <UserID>01</UserID>
            <Password>xxxxxxxxx</Password>
            <ReportTypes>
                <Type>XML2.02</Type>
            </ReportTypes>
        </Communications>
    </ns1:inCommunications>
    <ns1:inOrder/>
</ns1:OrderInteractive>

如果你看,订单参数只是空的。我的问题是为什么 SOAP 会剥离订单块,或者为什么订单块是空的?我还尝试了其他 2 种调用该函数的方法,但这两种方法都会在我的错误日志中记录:

"The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'OrderInteractive'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'InOrder' from namespace ''. Line 2, position 185."

我的代码如下:

    $commsBlock = "<Communications>
                <Host>Online</Host>
                <Account>xxxxx</Account>
                <UserID>01</UserID>
                <Password>xxxxxxxxx</Password>
                <ReportTypes>
                    <Type>XML2.02</Type>
                </ReportTypes>
            </Communications>";

    $orderBlock = "<Order>
                <Handling>OL</Handling>
                <Account>xxxxx</Account>
                <ProductID>DL</ProductID>
                <State>
                    <Abbrev>" . $order['state'] . "</Abbrev>
                    <Full></Full>
                </State>
                <Subtype>3Y</Subtype>
                <Purpose>AA</Purpose>
                <License>" . $order['dln'] . "</License>
                <FirstName>" . $order['firstname'] . "</FirstName>
                <MiddleName>" . $order['middlename'] . "</MiddleName>
                <LastName>" . $order['lastname'] . "</LastName>
                <DOB>
                    <Year>" . date('Y', $order['dob']) . "</Year>
                    <Month>" . date('m', $order['dob']) . "</Month>
                    <Day>" . date( 'd', $order['dob']) . "</Day>
                </DOB>
                <Misc>TEST ORDER INTERACTIVE</Misc>
            </Order>";

    $soap_url = 'https://demo2.mvrs.com/AdrConnect/AdrConnectWebService.svc?singlewsdl'; // test system url
    $soap_params = array(
        'trace' => true,
        'exceptions' => true,
        'cache_wsdl' => false
    );
    $_client = new SoapClient($soap_url, $soap_params);
    $params = array("inCommunications" => $commsBlock, "inOrder" => $orderBlock);

    // TRY TO SEND
    try {
        $_client->OrderInteractive($params); // works, but sends broken order node
        //$_client->__soapCall('OrderInteractive', $params); // breaks, goes to catch
        //$_client->OrderInteractive(new SoapParam($commsBlock, 'InCommunications'), new SoapParam($orderBlock, 'InOrder')); // breaks, goes to catch
    } catch(SoapFault $e) {
        capDebug(__FILE__, __LINE__, "Error: SoapFault:\n"  . $e->getMessage(), '/tmp/SOAP_errors.log');
    }
class inOrder {
function inOrder($xml) {
        $this->OrderXml = $xml;
    }
}

$xml_order = '<Order>
<Handling>OL</Handling>
<ProductID>DL</ProductID>
.
.
.
<Misc>TEST ORDER INTERACTIVE</Misc></Order>';

// create our order object that is needed
$order = new inOrder($xml_order);

// create our OrderInteractive parameters
$parameters = array(
    "inCommunications" => $xml_communication,
    "inOrder"          => $order
);
try {
    $xml = $_client->OrderInteractive($parameters);
} catch (Exception $e) {
    print $e->getMessage() . "\n"; exit();
}

上面的代码有效。 WSDL 需要一个字符串和一个对象作为参数。为订单创建了一个 class 并为通信块使用了一个字符串,我们正在正常接收数据。