PHP SoapClient: multiple complex types are overwritten in soapcall

[亡魂溺海] 提交于 2019-12-11 11:53:40

问题


I'm having a problem with a soapclient call. The soaprequest has to look like:

      <eng:Compose>
     <!--Optional:-->
     <EWSComposeRequest>
        <!--Optional:-->
        <driver>
           <!--Optional:-->
           <driver>base64</driver>
           <!--Optional:-->
           <fileName>INPUT</fileName>
        </driver>
         <engineOptions>   
            <name>FILEMAP</name>
            <value>DLFOUT.dlf,dummy.dlf</value>
         </engineOptions>
         <engineOptions>
            <name>FILEMAP</name>
            <value>PDFOUT.pdf,dummy.pdf</value>     
         </engineOptions>
         <engineOptions>
            <name>RUNMODE</name>
        <value>PRODUCTION</value>           
        </engineOptions>
        <!--Optional:-->
        <fileReturnRegEx>^.*.(dlf|pdf)$</fileReturnRegEx>
        <includeHeader>True</includeHeader>
        <includeMessageFile>True</includeMessageFile>
        <!--Optional:-->
        <pubFile>TestLive.pub</pubFile>
     </EWSComposeRequest>
  </eng:Compose>

My soap_param is:

$soap_param = array("Compose"=> array("EWSComposeRequest" => 
        array( "driver" => array( "driver" => $post_Driver, 
        "fileName" => $post_FileName), 
        "engineOptions" => array( "name" => "KEY", "value" => $INI['encodedkey']),
        "engineOptions" => array( "name" => "RUNMODE", "value" => $INI['runmode']), 
        "fileReturnRegEx" => $post_FileReturnRegEx, "includeHeader" => $post_IncludeHeader,
        "includeMessageFile" => $post_IncludeMessage, "pubFile" => $post_PubFile)));

The soapcall appears to work, however.... I only reveive the last engineOptions element. According to the xsd the element engineOptions can appear multiple times(0 to unbounded). Witin the soapcall this element seems to be overwritten. The index: engineOptions isn't unique.

I can't imagine that i am the only one facing this problem. I hope that there is a (simple) solution for this problem.


回答1:


With special thanks to: András Szepesházi. The following $soap_param definition:

$soap_param => array(
    'Compose' => array(
        'EWSComposeRequest' => array(
            'driver' => array( 
                'driver' => $post_Driver, 
                'fileName' => $post_FileName
            ),
            'engineOptions' => array(
                array(
                    'name' => 'KEY', 
                    'value' => $INI['encodedkey']
                ), 
                array(                     
                    'name' => 'RUNMODE', 
                    'value' => $INI['runmode']
                ), 
                array(
                    'name' => 'FILEMAP', 
                    'value' => "DLFOUT.dlf,dummy.dlf"
                ), 
                array(
                    'name' => 'FILEMAP',
                    'value' => "PDFOUT.pdf,dummy.pdf"
                ),
            ),
            'fileReturnRegEx' => $post_fileReturnPattern, 
            'includeHeader' => $post_IncludeHeader, 
            'includeMessageFile' => $post_IncludeMessage, 
            'pubFile' => $post_PubFile
        )
    )
);

Is able to create the following SOAP Request:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:hpexstream-services/Engine">
    <SOAP-ENV:Header>
        <ns1:n>n</ns1:n>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:Compose>
            <EWSComposeRequest>
                <driver>
                    <driver>base64</driver>
                    <fileName>INPUT</fileName>
                </driver>
                <engineOptions>
                    <name>KEY</name>
                    <value>base64</value>
                </engineOptions>
                <engineOptions>
                    <name>RUNMODE</name>
                    <value>PRODUCTION</value>
                </engineOptions>
                <engineOptions>
                    <name>FILEMAP</name>
                    <value>DLFOUT.dlf,dummy.dlf</value>
                </engineOptions>
                <engineOptions>
                    <name>FILEMAP</name>
                    <value>PDFOUT.pdf,dummy.pdf</value>
                </engineOptions>
                <includeHeader>true</includeHeader>
                <includeMessageFile>true</includeMessageFile>
                <pubFile>TestLive.pub</pubFile>
            </EWSComposeRequest>
        </ns1:Compose>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

So problem solved.



来源:https://stackoverflow.com/questions/16416427/php-soapclient-multiple-complex-types-are-overwritten-in-soapcall

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!