Vixushr Posted August 24, 2011 Share Posted August 24, 2011 Helo, I need some help with downloading xml from remote server using SOAP in PHP this is sample SOAP code that i have from server: http://shop.megatrend.com/ClientWebServices/ClientWS.asmx POST /ClientWebServices/ClientWS.asmx HTTP/1.1 Host: shop.megatrend.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://shop.megatrend.com/ClientWebServices/GetProducts" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetProducts xmlns="http://shop.megatrend.com/ClientWebServices/"> <username>string</username> <password>string</password> <OIB>string</OIB> </GetProducts> </soap:Body> </soap:Envelope> HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetProductsResponse xmlns="http://shop.megatrend.com/ClientWebServices/"> <GetProductsResult> <WsProduct> <PN>string</PN> <Code>string</Code> <Name>string</Name> <Description>string</Description> <Manufacturer>string</Manufacturer> <Weight>decimal</Weight> <Available>boolean</Available> <Stock>int</Stock> <Warranty>string</Warranty> <Price>decimal</Price> <Images> <WsImage xsi:nil="true" /> <WsImage xsi:nil="true" /> </Images> <Descriptions> <WsDescriptionData xsi:nil="true" /> <WsDescriptionData xsi:nil="true" /> </Descriptions> </WsProduct> <WsProduct> <PN>string</PN> <Code>string</Code> <Name>string</Name> <Description>string</Description> <Manufacturer>string</Manufacturer> <Weight>decimal</Weight> <Available>boolean</Available> <Stock>int</Stock> <Warranty>string</Warranty> <Price>decimal</Price> <Images> <WsImage xsi:nil="true" /> <WsImage xsi:nil="true" /> </Images> <Descriptions> <WsDescriptionData xsi:nil="true" /> <WsDescriptionData xsi:nil="true" /> </Descriptions> </WsProduct> </GetProductsResult> </GetProductsResponse> </soap:Body> </soap:Envelope> this is piece of PHP code that i have that shud handle request: function megatrend_download() { $local = dirname(__FILE__); $path = $local."/xml/megatrend.xml"; $path1 = $local."/xml/megatrend1.xml"; $request = array('username'=>'xxx','password'=>'xxx','oib'=>'xxx'); postPage($request,'http://shop.megatrend.com/ClientWebServices/GetProducts'); $curl2 = curl_init(); curl_setopt($curl2, CURLOPT_URL, 'http://shop.megatrend.com/ClientWebServices/ClientWS.asmx'); curl_setopt($curl2, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl2, CURLOPT_HEADER, false); curl_setopt($curl2, CURLOPT_RETURNTRANSFER, true); ...rest of functions... I am clearly missing something but i just cant get it! Help! Link to comment https://forums.phpfreaks.com/topic/245643-php-and-soap/ Share on other sites More sharing options...
Vixushr Posted August 25, 2011 Author Share Posted August 25, 2011 ... Anyone? Link to comment https://forums.phpfreaks.com/topic/245643-php-and-soap/#findComment-1261770 Share on other sites More sharing options...
WebStyles Posted August 25, 2011 Share Posted August 25, 2011 please post whatever errors you're getting. Link to comment https://forums.phpfreaks.com/topic/245643-php-and-soap/#findComment-1261774 Share on other sites More sharing options...
Vixushr Posted August 31, 2011 Author Share Posted August 31, 2011 Helo, i am still fighting with it... iw tryed this way function megatrend_download() { $local = dirname(__FILE__); $path = $local."/xml/megatrend.xml"; $path1 = $local."/xml/megatrend1.xml"; $postData = array('username'=>'xxx','password'=>'xxx','OIB'=>'xxx'); $curl2 = curl_init(); curl_setopt($curl2, CURLOPT_URL, 'http://shop.megatrend.com/ClientWebServices/ClientWS.asmx'); curl_setopt($curl2, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl2, CURLOPT_HEADER, false); curl_setopt($curl2, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl2, CURLOPT_POSTFIELDS, $postData); but still error thit i get is: Server was unable to process request. ---> Data at the root level is invalid. Line 1, position 1. Link to comment https://forums.phpfreaks.com/topic/245643-php-and-soap/#findComment-1263845 Share on other sites More sharing options...
Vixushr Posted September 2, 2011 Author Share Posted September 2, 2011 anyone? Link to comment https://forums.phpfreaks.com/topic/245643-php-and-soap/#findComment-1264651 Share on other sites More sharing options...
silkfire Posted September 2, 2011 Share Posted September 2, 2011 What do you want to do? Do you have trouble fetching the XML or parsing it? Link to comment https://forums.phpfreaks.com/topic/245643-php-and-soap/#findComment-1264676 Share on other sites More sharing options...
Vixushr Posted September 2, 2011 Author Share Posted September 2, 2011 i have have trouble fetching it. Link to comment https://forums.phpfreaks.com/topic/245643-php-and-soap/#findComment-1264793 Share on other sites More sharing options...
silkfire Posted September 2, 2011 Share Posted September 2, 2011 Use this address: http://shop.megatrend.com/ClientWebServices/ClientWS.asmx?op=GetProducts Link to comment https://forums.phpfreaks.com/topic/245643-php-and-soap/#findComment-1264830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.