PHP Soap Client用单个字符串请求答案

时间:2019-02-02 11:45:08

标签: php xml soap

对于SOAP客户端请求,我有点不了解。

我希望有人可以提供帮助,我正在尝试向网站提出肥皂客户请求。我可以发出请求,但是返回的XML(我正在变成一个数组)似乎是一个未分离为XML元素的字符串。

XML:

<ProductList>
<Product>
    <ProductCode>00380</ProductCode>
    <ProductName>Droopy Eye Specs</ProductName>
    <BrochureDescription>Droopy Eye Specs, Black, with Metal Spring, on Display Card</BrochureDescription>
    <WebDescription>Droopy Eye Specs, Black, with Metal Spring</WebDescription>
    <WashingInstructions>Not Applicable</WashingInstructions>
    <RRP>1.8900</RRP>
    <StockQuantity>943</StockQuantity>
    <VatRate>20.00</VatRate>
    <Gender>UNISEX</Gender>
    <PackType>on Display Card</PackType>
    <PackQty>1</PackQty>
    <Audience>ADULT</Audience>
    <Colour>BLACK</Colour>
    <ETA>2019-07-04 00:00:00.</ETA>
    <CataloguePage>641</CataloguePage>
    <BarCode>5020570003800</BarCode>
    <Price1>0.91</Price1>
    <Price2>0.00</Price2>
    <Price3>0.00</Price3>
    <Break1>1.00</Break1>
    <Break2>0.00</Break2>
    <Break3>0.00</Break3>
    <unit_size>1</unit_size>
    <warnings/>
    <carton>120</carton>
    <stdPrice1>0.91</stdPrice1>
    <stdPrice2>0.00</stdPrice2>
    <stdPrice3>0.00</stdPrice3>
    <stdBreak1>12.00</stdBreak1>
    <stdBreak2>0.00</stdBreak2>
    <stdBreak3>0.00</stdBreak3>
    <Photo>1</Photo>
    <CatalogueCode>JN-01</CatalogueCode>
    <CatalogueName>Jokes & Novelties_Assorted</CatalogueName>
    <Catalogue/>
    <acc_code1>32928</acc_code1>
    <acc_code2>32929</acc_code2>
    <alt_code1>20073</alt_code1>
    <alt_code2>25202</alt_code2>
    <alt_code3>29111</alt_code3>
    <alt_code4>6155</alt_code4>
    <alt_code5>98413</alt_code5>
    <new_code/>
    <art_cat/>
    <ImageAvailability>No</ImageAvailability>
    <Seasonal>No</Seasonal>
    <p_list2/>
    <Licence_Territory/>
    <ThemeName>Funnyside Fancy Dress</ThemeName>
    <GroupID>3</GroupID>
    <GroupName>Adult Fancy Dress Costumes</GroupName>
    <GroupID1>0</GroupID1>
    <ThemeGroup1>Uncategorized</ThemeGroup1>
    <GroupID2>0</GroupID2>
    <ThemeGroup2>Uncategorized</ThemeGroup2>
    <GroupID3>0</GroupID3>
    <ThemeGroup3>Uncategorized</ThemeGroup3>
    <EFPrice>0.9100</EFPrice>
    <EFQty>1</EFQty>
    <size>Not Applicable</size>
    <Ext_Size>NOT APPLICABLE</Ext_Size>
    <GenericCode>00380</GenericCode>
    <HasImageRights>No</HasImageRights>
    <Safety>Warning! Not suitable for children under 3 years due to small parts. Choking Hazard.</Safety>
    <Composition/>
</Product>
<Product>
    <ProductCode>00429</ProductCode>
    <ProductName>Metal Handcuffs</ProductName>
    <BrochureDescription>Metal Handcuffs, Silver, with Key, on Display Card</BrochureDescription>
    <WebDescription>Metal Handcuffs, Silver, with Key</WebDescription>
    <WashingInstructions>Not Applicable</WashingInstructions>
    <RRP>3.0900</RRP>
    <StockQuantity>4926</StockQuantity>
    <VatRate>20.00</VatRate>
    <Gender>UNISEX</Gender>
    <PackType>on Display Card</PackType>
    <PackQty>1</PackQty>
    <Audience>ADULT</Audience>
    <Colour>SILVER</Colour>
    <ETA>2019-02-10 00:00:00.</ETA>
    <CataloguePage>424</CataloguePage>
    <BarCode>5020570004296</BarCode>
    <Price1>1.50</Price1>
    <Price2>0.00</Price2>
    <Price3>0.00</Price3>
    <Break1>1.00</Break1>
    <Break2>0.00</Break2>
    <Break3>0.00</Break3>
    <unit_size>1</unit_size>
    <warnings>FREIG, FREIG,</warnings>
    <carton>96</carton>
    <stdPrice1>1.50</stdPrice1>
    <stdPrice2>0.00</stdPrice2>
    <stdPrice3>0.00</stdPrice3>
    <stdBreak1>3.00</stdBreak1>
    <stdBreak2>0.00</stdBreak2>
    <stdBreak3>0.00</stdBreak3>
    <Photo>1</Photo>
    <CatalogueCode>AC-30</CatalogueCode>
    <CatalogueName>Accessories_Truncheons & Handcuffs</CatalogueName>
    <Catalogue/>
    <acc_code1>29535</acc_code1>
    <acc_code2>33723</acc_code2>
    <acc_code3>96318</acc_code3>
    <alt_code1>23076</alt_code1>
    <alt_code2>23918</alt_code2>
    <alt_code3>30652</alt_code3>
    <alt_code4>34757</alt_code4>
    <alt_code5>374</alt_code5>
    <new_code/>
    <art_cat/>
    <ImageAvailability>No</ImageAvailability>
    <Seasonal>No</Seasonal>
    <p_list2/>
    <Licence_Territory/>
    <ThemeName>Cops & Robbers Fancy Dress</ThemeName>
    <GroupID>3</GroupID>
    <GroupName>Adult Fancy Dress Costumes</GroupName>
    <GroupID1>0</GroupID1>
    <ThemeGroup1>Uncategorized</ThemeGroup1>
    <GroupID2>0</GroupID2>
    <ThemeGroup2>Uncategorized</ThemeGroup2>
    <GroupID3>0</GroupID3>
    <ThemeGroup3>Uncategorized</ThemeGroup3>
    <EFPrice>1.5000</EFPrice>
    <EFQty>1</EFQty>
    <size>Not Applicable</size>
    <Ext_Size>NOT APPLICABLE</Ext_Size>
    <GenericCode>00429</GenericCode>
    <HasImageRights>No</HasImageRights>
    <Safety>Warning! Not suitable for children under 3 years due to small parts - Choking Hazard. Keep these details for reference. Warning! Do not over tighten as this may cause the safety catch to jam. INSTRUCTIONS: 1. LOCK Move stop bar to upper position, press cuff down on wrist and rotate the jaw until it engages ratchet. Jaw may be tightened as required. Do not over tighten. Move stop bar to down position, jaw is thus locked against travel in either direction. 2. UNLOCK Move stop bar to open</Safety>
    <Composition/>
</Product>

我的PHP:

$apiKey = '00000';
$clientID = 'MyID';
$LanguageCode = 'EN';
$wdsl = 'http://webservices.website.com/services/products.asmx?WSDL';

$params = array('apiKey' => $apiKey, 'clientID' => $clientID);

$soapclient = new SoapClient($wdsl);

$response = $soapclient->GetFullDataSet($params);

$array = json_decode(json_encode($response), true);

print_r ($array);

返回的数组:

Array ( [GetFullDataSetResult] => Array ( [any] => 00380Droopy Eye SpecsDroopy Eye Specs, Black, with Metal Spring, on Display CardDroopy Eye Specs, Black, with Metal SpringNot Applicable1.890094320.00UNISEXon Display Card1ADULTBLACK2019-07-04 00:00:00.64150205700038000.910.000.001.000.000.0011200.910.000.0012.000.000.001JN-01Jokes & Novelties_Assorted3292832929200732520229111615598413NoNoFunnyside Fancy Dress3Adult Fancy Dress Costumes0Uncategorized0Uncategorized0Uncategorized0.91001Not ApplicableNOT APPLICABLE00380NoWarning! Not suitable for children under 3 years due to small parts. Choking Hazard.00429Metal HandcuffsMetal Handcuffs, Silver, with Key, on Display CardMetal Handcuffs, Silver, with KeyNot Applicable3.0900492620.00UNISEXon Display Card1ADULTSILVER2019-02-10 00:00:00.42450205700042961.500.000.001.000.000.001FREIG, FREIG, 961.500.000.003.000.000.001AC-30Accessories_Truncheons & Handcuffs29535337239631823076239183065234757374NoNoCops & Robbers Fancy Dress3Adult Fancy Dress Costumes0Uncategorized0Uncategorized0Uncategorized1.50001Not ApplicableNOT APPLICABLE00429NoWarning! Not suitable for children under 3 years due to small parts - Choking Hazard. Keep these details for reference. Warning! Do not over tighten as this may cause the safety catch to jam. INSTRUCTIONS: 1. LOCK Move stop bar to upper position, press cuff down on wrist and rotate the jaw until it engages ratchet. Jaw may be tightened as required. Do not over tighten. Move stop bar to down position, jaw is thus locked against travel in either direction. 2. UNLOCK Move stop bar to open

如何将XML元素作为每个元素放入数组中?

例如。产品>产品代码>产品名称>手册描述>等等...

让我知道是否有任何我错过的信息。任何帮助将不胜感激。

非常感谢。

0 个答案:

没有答案