通过PHP数组的SOAP xml请求

时间:2015-08-10 17:08:22

标签: php arrays xml soap request

我现在正在努力解决这个问题一周,我真的需要一些帮助,因为我无法进一步考虑任何解决方案。 我正在尝试与SOAP服务进行通信。我有在SoapUI中测试的示例,它们在那里工作正常。当我使用PHP函数__doRequest发送XML字符串时,它也可以工作,但我的目标是将XML字符串结构化为PHP数组。我尝试过使用多个转换器XML-> JSON->数组,也试图自己编写它,并从原始XML到数组使用函数" simple_xml_load_string"然后将其解码为JSON而不是数组但是再次没有成功。服务器继续响应未定义的错误。

        <soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ser="www.somens.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Header>
          <wsse:Security>
             <wsse:UsernameToken>
                <wsse:Username>*******</wsse:Username>
                <wsse:Password>********</wsse:Password>
             </wsse:UsernameToken>
          </wsse:Security>
       </soapenv:Header>
       <soapenv:Body>
          <ser:MTPLRegisterApplication>
             <ser:request>
                <req:Client>
                   <Entity>
                      <PersonalData>
                         <Name>
                            <Given>Тома</Given>
                            <Surname>Иванов</Surname>
                            <Family>Петков</Family>
                         </Name>
                         <PID>987987987</PID>
                         <Gender>2</Gender>
                         <BirthDate>1986-11-24</BirthDate>
                      </PersonalData>
                   </Entity>
                   <Addresses>
                      <Address>
                         <Country>България</Country>
                         <CountryCode>BG</CountryCode>
                         <State>София</State>
                         <CountryState>SFO</CountryState>
                         <Region>Антон</Region>
                         <StateRegion>SFO54</StateRegion>
                         <City>Антон</City>
                         <CityCode>00504</CityCode>
                         <ResidentialAddress>
                            <StreetName>ул. Равнец №7</StreetName>
                         </ResidentialAddress>
                         <ZipCode>2089</ZipCode>
                         <AddressType>H</AddressType>
                      </Address>
                   </Addresses>
                </req:Client>
                <req:Insureds>
                   <Insured>
                      <InsuredEntity>
                         <ObjectID>-1</ObjectID>
                         <Owners>
                            <Owner>
                               <Entity>
                                  <PersonalData>
                                     <Name>
                                        <Given>Тома</Given>
                                        <Surname>Иванов</Surname>
                                        <Family>Петков</Family>
                                     </Name>
                                     <PID>9879879879</PID>
                                     <Gender>2</Gender>
                                     <BirthDate>1986-11-24</BirthDate>
                                  </PersonalData>
                               </Entity>
                               <Addresses>
                                  <Address>
                                     <Country>България</Country>
                                     <CountryCode>BG</CountryCode>
                                     <State>София</State>
                                     <CountryState>SFO</CountryState>
                                     <Region>Антон</Region>
                                     <StateRegion>SFO54</StateRegion>
                                     <City>Антон</City>
                                     <CityCode>00504</CityCode>
                                     <ResidentialAddress>
                                        <StreetName>ул. Равнец №7</StreetName>
                                     </ResidentialAddress>
                                     <ZipCode>2089</ZipCode>
                                     <AddressType>H</AddressType>
                                  </Address>
                               </Addresses>
                               <BeginDate>2010-06-15</BeginDate>
                            </Owner>
                         </Owners>
                         <RelatedPersons>
                            <RelatedPerson>
                               <OthersData>
                                  <AddressID>116</AddressID>
                               </OthersData>
                               <PID>987987987</PID>
                               <PersonType>116</PersonType>
                               <AnnexID>0</AnnexID>
                               <ProductCode>4307</ProductCode>
                               <IncludedPolicy>Y</IncludedPolicy>
                               <Entity>
                                  <PersonalData>
                                     <Name>
                                        <Given>Тома</Given>
                                        <Surname>Иванов</Surname>
                                        <Family>Петков</Family>
                                     </Name>
                                     <PID>987987987</PID>
                                     <Gender>2</Gender>
                                     <BirthDate>1986-11-24</BirthDate>
                                  </PersonalData>
                               </Entity>
                               <Addresses>
                                  <Address>
                                     <Country>България</Country>
                                     <CountryCode>BG</CountryCode>
                                     <State>София</State>
                                     <CountryState>SFO</CountryState>
                                     <Region>Антон</Region>
                                     <StateRegion>SFO54</StateRegion>
                                     <City>Антон</City>
                                     <CityCode>00504</CityCode>
                                     <ResidentialAddress>
                                        <StreetName>ул. Равнец №7</StreetName>
                                     </ResidentialAddress>
                                     <ZipCode>2089</ZipCode>
                                     <AddressType>H</AddressType>
                                  </Address>
                               </Addresses>
                            </RelatedPerson>
                         </RelatedPersons>
                         <OCar>
                            <RegNo>A9625C</RegNo>
                            <CarType>1</CarType>
                            <Model>LAGUNA</Model>
                            <Make>РЕНО</Make>
                            <Chassis>KLATF19TH0B448344</Chassis>
                            <Engine>*</Engine>
                            <CCMTon>2300</CCMTon>
                            <CarUsage>1</CarUsage>
                            <SeatsNum>4</SeatsNum>
                            <DoorNum>2</DoorNum>
                            <PaintType>3</PaintType>
                            <ProdYear>2005</ProdYear>
                            <ProdType>3</ProdType>
                            <CarColor>10</CarColor>
                            <RegType>1</RegType>
                            <Tonage>0.0</Tonage>
                            <EngineType>1</EngineType>
                            <FuelType>P</FuelType>
                            <Modified>0</Modified>
                            <CustomProperties>
                               <CustomProperty>
                                  <FieldName>OCP1</FieldName>
                                  <ProductCode>4307</ProductCode>
                                  <Value>*</Value>
                                  <!--greencard value-->
                               </CustomProperty>
                            </CustomProperties>
                         </OCar>
                      </InsuredEntity>
                      <InsuredAmount>0</InsuredAmount>
                      <Currency>BGL</Currency>
                      <IsRegularlyOutsideBulgariaMoreThanSixtyDays>false</IsRegularlyOutsideBulgariaMoreThanSixtyDays>
                      <Covers>
                         <Cover>
                            <CoverCode>MPSTPL_GR</CoverCode>
                            <AnnexID>0</AnnexID>
                            <InsuredAmount>0</InsuredAmount>
                            <Currency>BGL</Currency>
                            <PremiumType>T</PremiumType>
                         </Cover>
                         <Cover>
                            <CoverCode>M_ACC1</CoverCode>
                            <ObjectNum>1</ObjectNum>
                            <AnnexID>0</AnnexID>
                            <InsuredAmount>1000</InsuredAmount>
                            <Currency>BGL</Currency>
                            <PremiumType>T</PremiumType>
                         </Cover>
                      </Covers>
                      <CustomProperties>
                         <CustomProperty>
                            <FieldName>IOP3</FieldName>
                            <ProductCode>4307</ProductCode>
                            <Value>*</Value>
                            <!--sticker value-->
                         </CustomProperty>
                      </CustomProperties>
                   </Insured>
                </req:Insureds>
                <req:InsuranceConditions>
                   <!--<PolicyNo xsi:nil="true"/>-->
                   <AgentID>***********</AgentID>
                   <ProductCode>4307</ProductCode>
                   <IssueDate>2015-08-10</IssueDate>
                   <ConclusionDate>2015-08-10</ConclusionDate>
                   <EffectiveDate>2015-08-10T23:00:00+02:00</EffectiveDate>
                   <Duration>1</Duration>
                   <DurationUnits>y</DurationUnits>
                   <Installments>1</Installments>
                   <PaymentWay>1</PaymentWay>
                   <Renewal>0</Renewal>
                   <CommonConditions>
                      <Condition>
                         <Type>SPEC_RISK</Type>
                         <Dimension>D</Dimension>
                      </Condition>
                      <data:Condition>
                         <data:Type>WSREG1</data:Type>
                         <data:Dimension>F</data:Dimension>
                         <data:Value/>
                      </data:Condition>
                   </CommonConditions>
                </req:InsuranceConditions>
             </ser:request>
          </ser:MTPLRegisterApplication>
       </soapenv:Body>
    </soapenv:Envelope>

我将非常感谢每一位试图帮助我的人。 提前谢谢。

0 个答案:

没有答案