douli0531 2019-02-02 11:45
浏览 71

PHP Soap Client使用单个String请求答案

I'm a bit of an noob when it comes to SOAP client requests.

I'm hoping someone could help, I'm trying to make a soap client request to a website. I can make the request however the returned XML (which I'm turning into an Array) seems to come as a single string not separated into the XML elements.

The 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>

My 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);

the Returned 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

How do I get the XML elements in to the Array as Each Element?

Eg. Product > Productcode > ProductName > BrochureDescription > Etc...

Let me know if there is any info I've missed out. Any Help would be appreciate.

Many thanks.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?