如何使用重复的数组键进行SOAP复杂类型调用?

时间:2018-11-12 11:52:44

标签: php soap wsdl

我有2个问题,或者似乎无法解决。

问题 SOAP:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns11:createBusinessInteraction xmlns:ns11="http://test.com/services/common/businessinteraction/v1" xmlns:ns10="http://test.com/services/common/base/v1" xmlns:ns12="http://test.com/services/common/customer/v1" xmlns:ns2="http://test.com/schemas/common/base/v1" xmlns:ns3="http://test.com/schemas/common/party/v1" xmlns:ns4="http://test.com/schemas/common/location/v1" xmlns:ns5="http://test.com/schemas/common/dealer/v1" xmlns:ns6="http://test.com/schemas/common/businessinteraction/v1" xmlns:ns7="http://test.com/schemas/common/customer/v1" xmlns:ns8="http://test.com/schemas/product/fulfillment/v1" xmlns:ns9="http://test.com/schemas/product/lifecycle/v1">
         <ns11:createBusinessInteractionRequestMsg>
            <ns10:header>
               <ns10:source>Someting</ns10:source>
               <ns10:destination>MM</ns10:destination>
               <ns10:origin>Someting</ns10:origin>
               <ns10:transactionId>6483fd9a-9bb9-4517-8341-f455146ad0af</ns10:transactionId>
            </ns10:header>
            <ns11:businessInteraction xsi:type="ns6:BusinessInteractionEmail" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <ns2:characteristicCollection>
                  <ns2:characteristic>
                     <ns2:type>
                        <ns2:value>MM_SOURCE</ns2:value>
                     </ns2:type>
                     <ns2:catalogValue>
                        <ns2:id>37</ns2:id>
                        <ns2:value>010100100</ns2:value>
                        <ns2:catalogName>BusinessInteraction.AdditionalProperty</ns2:catalogName>
                     </ns2:catalogValue>
                  </ns2:characteristic>
               </ns2:characteristicCollection>
               <ns6:priority>
                  <ns2:id>2</ns2:id>
               </ns6:priority>
               <ns6:interactingRoleCollection>
                  <ns6:businessInteractionRole xsi:type="ns6:BusinessInteractionPartyRole">
                     <ns6:identifierValue>12345678</ns6:identifierValue>
                     <ns6:roleType>
                        <ns2:id>1</ns2:id>
                     </ns6:roleType>
                  </ns6:businessInteractionRole>
               </ns6:interactingRoleCollection>
               <ns6:businessInteractionItemCollection>
                  <ns6:businessInteractionItem>
                     <ns6:businessInteractionRoleCollection>
                        <ns6:businessInteractionRole xsi:type="ns6:BusinessInteractionPartyRole">
                           <ns6:identifierValue>12345678</ns6:identifierValue>
                           <ns6:roleType>
                              <ns2:id>1</ns2:id>
                           </ns6:roleType>
                        </ns6:businessInteractionRole>
                     </ns6:businessInteractionRoleCollection>
                     <ns6:topicGroupCollection>
                        <ns6:topicGroup>
                           <ns6:topicCollection>
                              <ns6:topic>
                                 <ns2:id>1000024</ns2:id>
                                 <ns2:catalogName>BusinessInteraction.Topic.Job</ns2:catalogName>
                              </ns6:topic>
                              <ns6:topic>
                                 <ns2:id>2000228</ns2:id>
                                 <ns2:catalogName>BusinessInteraction.Topic.GroupServices</ns2:catalogName>
                              </ns6:topic>
                           </ns6:topicCollection>
                        </ns6:topicGroup>
                     </ns6:topicGroupCollection>
                     <ns6:attachmentCollection>
                        <ns6:attachment>
                           <ns2:title>some.pdf</ns2:title>
                           <ns2:documentContent xsi:type="ns2:File">
                              <ns2:content>f34rff</ns2:content>
                              <ns2:name>some.pdf</ns2:name>
                              <ns2:extension>pdf</ns2:extension>
                           </ns2:documentContent>
                        </ns6:attachment>
                     </ns6:attachmentCollection>
                  </ns6:businessInteractionItem>
               </ns6:businessInteractionItemCollection>
               <ns6:recipients>test@test.si</ns6:recipients>
               <ns6:sender>test@test.si</ns6:sender>
            </ns11:businessInteraction>
         </ns11:createBusinessInteractionRequestMsg>
      </ns11:createBusinessInteraction>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

这种compley类型(xsi:type和xmlns:xsi)存在问题:

<ns11:businessInteraction xsi:type="ns6:BusinessInteractionEmail" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

这是我的代码:

$client = new SoapClient("http://service.test.com:80/services/common/businessinteraction/v1/BusinessInteractionService/v/1.8.0?wsdl",array('login'=> "myusername",
        'password'=> "Test123"));

$param = array(
        'createBusinessInteractionRequestMsg' => array(
            'header' => array(
                'origin' => 'Test'
            ),
            'businessInteraction' => array(
                'originApplication' => array('id' => 31),   //31
                'user' => array('username' => 'myusername'),
                'channel' => array('id' => 2),  //2
                'origin' => array('id' => 2),   //2
                'note' => 'Something',
                'subject' => 'Some subject',
                'status' => array('id' => 2),
                'priority' => array('id' => 2), //2
                'interactingRoleCollection' => array(
                    'businessInteractionRole' => array(
                        'identifierValue' => 12345678,
                        'roleType' => array('id' => 1)
                    )
                ),
                'businessInteractionItemCollection' => array(
                    'businessInteractionItem' => array(
                        'businessInteractionRoleCollection' => array(
                            'businessInteractionRole' => array(
                                'identifierValue' => 112047,
                                'roleType' => array('id' => 1)
                            )
                        ),
                        'subject' => 'Something',
                        'topicGroupCollection' => array(
                            'topicGroup' => array(
                                'topicCollection' => array(
                                    'topic' => array(
                                        'id' => array(2000266,1000004),
                                        'catalogName' => array('BusinessInteraction.Topic.Job','BusinessInteraction.Topic.GroupServices')
                                    )
                                ),
                                'classification' => array(
                                    'id' => 1,
                                    'catalogName' => 'BusinessInteraction.TopicClassification'
                                )
                            )
                        )
                    )
                ),
                'recipients' => 'test@test.com',
                'sender' => 'test@test.com'
            )
        )
    );

$value = $client->createBusinessInteraction($param);

起初,我在重复键方面遇到问题。所以从这个:

'topicGroupCollection' => array(
                            'topicGroup' => array(
                                'topicCollection' => array(
                                    'topic' => array( 
                                        'id' => array(10000024),
                                        'catalogName' => array('BusinessInteraction.Topic.Job','BusinessInteraction.Topic.GroupServices')
                                    ),
                                    'topic' => array(
                                        'id' => array(2000266),
                                        'catalogName' => array('BusinessInteraction.Topic.Job','BusinessInteraction.Topic.GroupServices')
                                    )
                                ),
                                'classification' => array(
                                    'id' => 1,
                                    'catalogName' => 'BusinessInteraction.TopicClassification'
                                )
                            )
                        )

我将其更改为:

'topicGroupCollection' => array(
                            'topicGroup' => array(
                                'topicCollection' => array(
                                    'topic' => array(
                                        'id' => array(2000266,1000004),
                                        'catalogName' => array('BusinessInteraction.Topic.Job','BusinessInteraction.Topic.GroupServices')
                                    )
                                ),
                                'classification' => array(
                                    'id' => 1,
                                    'catalogName' => 'BusinessInteraction.TopicClassification'
                                )
                            )
                        )
  1. 那为什么我会从不存在该阵列的服务器上收到错误消息?

  2. 如何将复杂类型添加到所提到的元素?

0 个答案:

没有答案