PHP - How To Parse This Soap Request
I am looking for some help parsing the SOAP request below:
Code: [Select] try { $aSoapConnectionOptions = array( 'cache_wsdl' => WSDL_CACHE_BOTH, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'encoding' => 'ISO-8859-1', 'trace' => 1 ); $client = new SoapClient(WSDL_URI, $aSoapConnectionOptions); $xml = '<?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> <ReceiveData xmlns="GDWebService"> <value> <![CDATA[ <?xml version="1.0" encoding="utf-8"?> <XMLRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Description>EventsOnlyListLoad</Description> <Item xsi:type="XMLEventsOnlyRequest"> <RangeStartDate>01/01/2006</RangeStartDate> <RangeEndDate>01/12/2012</RangeEndDate> <ResType /> <ResView>Web Sales Events</ResView> </Item> </XMLRequest> ]]> </value> </ReceiveData> </soap:Body> </soap:Envelope>'; $response = $client->__doRequest($xml,REQUEST_URL,"GDWebService/ReceiveData",'1.1'); When I print out the response, I get the following: Code: [Select] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><ReceiveDataResponse xmlns="GDWebService"><ReceiveDataResult><?xml version="1.0"?> <ResourceList xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ResList> <anyType xsi:type="XMLEventsOnly"> <AVAILABLE>0</AVAILABLE> <EVENTNAME>Test Event</EVENTNAME> <RESTYPE>Families</RESTYPE> <TotalBooked>0</TotalBooked> <StartTime>11:00</StartTime> <ID>0069</ID> <EventCode>0000003701</EventCode> <EventDate>30/05/2011</EventDate> <EventDescription> </EventDescription> <Capacity>0</Capacity> <ProductMapID> </ProductMapID> <LongDescription> </LongDescription> <ImageLink> </ImageLink> <MINPERBOOKING>0</MINPERBOOKING> <MAXPERBOOKING>0</MAXPERBOOKING> <ValidFrom> </ValidFrom> <ValidTo> </ValidTo> <AdditionalInfo> </AdditionalInfo> <ValidDays> </ValidDays> <MoreInfoLink> </MoreInfoLink> </anyType> </ResList> <EventsOnly>false</EventsOnly> </ResourceList></ReceiveDataResult></ReceiveDataResponse></soap:Body></soap:Envelope> I want to be able to get the response as an object so I can easily loop through the ResList. Currently, the only way I seem to be able to do this is by doing the following but I know it's not the best code: Code: [Select] $response = str_replace("xmlns=\"GDWebService\"", "", $response); $response = str_replace("soap:Body","body",$response); $response = simplexml_load_string($response); $response = $response->body->ReceiveDataResponse->ReceiveDataResult; $response = simplexml_load_string($response); if($response->ResList) foreach($response->ResList->anyType as $Item){ //echo data here } Hope someone can help. Thanks Similar TutorialsI working one paracel SOAP api and im totally crazy already. I need send that code: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://service.core.epmx.application.eestipost.ee/xsd"> <soapenv:Header/> <soapenv:Body> <xsd:businessToClientMsgRequest> <partner>KLIENDIKOOD</partner> <interchange msg_type="elsinfov1"> <header file_id="201805030022" sender_cd="KLIENDIKOOD"/> <item_list> <item service="PA"> <add_service> <option code="ST"/> <option code="SF"/> </add_service> <measures weight="1.000"/> <comment>testcomment</comment> <partnerId>12345</partnerId> <receiverAddressee> <person_name>TEST1</person_name> <mobile>55555555</mobile> <email>itest@test.ee</email> <address country="EE" offloadPostcode="96000"/> </receiverAddressee> <returnAddressee> <person_name>Sender name</person_name> <phone>55555555</phone> <mobile>55555555</mobile> <email>itest@test.lv</email> <address postcode="13811" deliverypoint="Tallinn" country="EE" street="Mahtra 7"/> </returnAddressee> </item> </item_list> </interchange> </xsd:businessToClientMsgRequest> </soapenv:Body> </soapenv:Envelope> If someone have no idea how create php script using SoapClient for that, then im happy to see result! :)
* What i tried is totally shit and didnt worked at all, so i better don't show my code :D Hi there I'm trying to get an answer for a soap request This is the info provided by the software house about the request: POST /myTest/Services.asmx HTTP/1.1 Host: 127.0.0.1 Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://------.--/myTest/Addons" <?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> <Addons xmlns="http://------.--/myTest/"> <hotelUnit>string</hotelUnit> <initialDate>dateTime</initialDate> <finalDate>dateTime</finalDate> <roomStays> <RoomStayOfPAX> <PaxPerRoom> <PAX xsi:nil="true" /> <PAX xsi:nil="true" /> </PaxPerRoom> <RoomType>string</RoomType> <Allotment> <Allotment>string</Allotment> </Allotment> </RoomStayOfPAX> <RoomStayOfPAX> <PaxPerRoom> <PAX xsi:nil="true" /> <PAX xsi:nil="true" /> </PaxPerRoom> <RoomType>string</RoomType> <Allotment> <Allotment>string</Allotment> </Allotment> </RoomStayOfPAX> </roomStays> <onlyFixedValue>boolean</onlyFixedValue> </Addons> </soap:Body> </soap:Envelope> I'm trying to use this code for the request passing the xml on $parameters $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$baseurl.$command); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT,180); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, "$login:$password"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $result = curl_exec($ch); if($result === false){ echo 'Curl error: ' . curl_error($ch); } else { //$result = simplexml_load_string($result); } curl_close($ch); return($result); But I get an invalid request. myTest is over a self signed ssl certificate and with basic authentication. Maybe the problem resides there or in the request itself. Anyone can help me with this ? Best regards. Hello, This is supposed to be a sample soap request. I don't know how to actually send the request with php. Code: [Select] POST /sendSms.asmx HTTP/1.1 Host: host_site.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://some_uri.com/sendSms" <?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> <sendSms xmlns="http://some_uri.com/"> <username>string</username> <password>string</password> <smsContent> <string>string</string> <string>string</string> </smsContent> <cell> <string>string</string> <string>string</string> </cell> <from>string</from> </sendSms> </soap:Body> </soap:Envelope> How am I supposed to so send this info? What is soapAction there? I tried: Code: [Select] $client = new SoapClient("host_site.com/sendSms.asmx"); and I'm getting: Quote Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'host_site.com/sendSms.asmx' : Premature end of data in tag html line 3 in ... Hi, I am attempting to download a report from Bing Ads, and am having issues with the level of nesting on the SOAP request for the date, (specifically 'Time' = >....) Definitely appreciate the help! SOAP elements can be found at https://docs.microsoft.com/en-us/advertising/reporting-service/date?view=bingads-13 for date and https://docs.microsoft.com/en-us/advertising/reporting-service/reporttime?view=bingads-13 using CustomDateRangeStart and CustomDateRangeEnd $request = [ 'ReportRequest' => new SoapVar( [ 'Format' => 'Csv', 'ReportName' => 'Bing Keyword Performance Report', 'ReturnOnlyCompleteData' => false, 'Aggregation' => 'Daily', 'Sort' => ['SortColumn' => 'Clicks'], 'Sort' => ['SortOrder' => 'Ascending'], 'Scope' => [['AccountIds' => [...]], ['CampaignId' => null], ['AdGroupId' => [...]]], 'Time' => ['CustomDateRangeStart' => ['Date' => ['Day' => $startDay],['Month' => $startMonth],['Year' => $startYear]]], 'Time' => ['CustomDateRangeEnd' => ['Date' => ['Day' => $endDay],['Month' => $endMonth],['Year' => $endYear]]], 'Filter' => ['BidMatchType' => [$mt]], 'Keywords' => array($criteriaValue), 'Columns' => [ "TimePeriod", "Spend", "Clicks", "CurrentMaxCpc", "Impressions", "AverageCpc", "TopVsOther", "QualityScore", "CampaignStatus", "AdGroupStatus", "BidMatchType", "AdGroupName" ] ], SOAP_ENC_OBJECT, 'KeywordPerformanceReportRequest', "https://bingads.microsoft.com/Reporting/v13" )]; Edited March 8, 2020 by Mike1020 Added a link for ReportTime data object
I am working with myDHL API and not getting a null response from their API. When i look into the fault code its showing an env:server. Their support is not helpful so need some help here. I tried using the Soap class using the code below $request=<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <soap:Header><wsse:Security soapenv:mustunderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken wsu:id = "UsernameToken-5" xmlns:wsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" > <wsse:Username > test</wsse:Username > <wsse:Password type = "PasswordText" >test</wsse:Password> <wsse:Nonce encodingtype = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" > eUYebYfsjztETJ4Urt8AJw ==</wsse:Nonce > <wsu:Created > 2020 - 04 - 24 20:17:21 </wsu:Created > </wsse:UsernameToken > </wsse:Security > </soap:Header> <soap:Body> <ShipmentRequest xmlns="http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/ShipmentMsgRequest"> <MessageId xmlns="">c68d7150bbd611e2b09ad103c98eed12</MessageId> <ClientDetail xmlns=""/> <RequestedShipment xmlns=""> <ShipmentInfo> <DropOffType>REGULAR_PICKUP</DropOffType> <ServiceType>P</ServiceType> <Account>4324324324</Account> <Currency>EUR</Currency> <UnitOfMeasurement>SI</UnitOfMeasurement> </ShipmentInfo> <ShipTimestamp>2019-10-24T14:01:22GMT+00:00</ShipTimestamp> <PaymentInfo>DDU</PaymentInfo> <InternationalDetail> <Commodities> <NumberOfPieces>1</NumberOfPieces> <Description>Documents</Description> <CustomsValue>10</CustomsValue> <CountryOfManufacture>ES</CountryOfManufacture> </Commodities> </InternationalDetail> <Ship> <Shipper> <Contact> <PersonName>Karlos Espana</PersonName> <CompanyName>SHIPING LTD</CompanyName> <PhoneNumber>3848211</PhoneNumber> </Contact> <Address> <StreetLines>DEL STREETO 9</StreetLines> <City>SANT CUGAT DEL VALLES</City> <PostalCode>08173</PostalCode> <CountryCode>ES</CountryCode> </Address> </Shipper> <Recipient> <Contact> <PersonName>Martin Soltys</PersonName> <CompanyName>DHL</CompanyName> <PhoneNumber>731731731</PhoneNumber> </Contact> <Address> <StreetLines>V Parku 2308/10</StreetLines> <City>Prague</City> <PostalCode>14800</PostalCode> <CountryCode>CZ</CountryCode> </Address> </Recipient> </Ship> <Packages> <RequestedPackages number="1"> <Weight>1</Weight> <Dimensions> <Length>35</Length> <Width>25</Width> <Height>1</Height> </Dimensions> <CustomerReferences>LC MAGIC NUMBER 0037</CustomerReferences> </RequestedPackages> </Packages> </RequestedShipment> </ShipmentRequest> </soap:Body> </soap:Envelope>
$url = 'https://wsbexpress.dhl.com:443/sndpt/expressRateBook'; $action = 'createShipmentRequest'; try { $client = new SoapClient($path_to_wsdl); $response =$client->createShipmentRequest($request); } catch (SoapFault $fault) { echo "<h2>SOAP Fault!</h2><p>"; echo "FaultCode: {$fault->faultcode} <br/>"; echo "FaultString: {$fault->faultstring} <br/>"; echo"</p/>"; }
We are trying to develop a Flight Reservation System. It communicates with a remote server using non-wsdl mode. The remote server requires a couple of ID's in the header. But whenever we try to connect to this server using the PHP Soap Client, it throws an error showing :- Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server.Exception:] Error occurred while trying to invoke requested method. in C:\xampp\htdocs\soap\two.php:41 Stack trace: #0 C:\xampp\htdocs\soap\two.php(41): SoapClient->__soapCall('getAvailability', Array) #1 {main} thrown in C:\xampp\htdocs\soap\two.php on line 41 Please let me know your thoughts on this and some inputs on executing SOAP requests. Thanks in Adv. Sam Hi guys, Im trying to work with a wsdl which allows me to login and sends back a token (cookie) in the response. Whenever I strip out the token and the use __setCookie to set the cookie for future requests all other requests will not authenticate... Anyone any ideas please? Im really at a loose end... Heres the code Im using... Code: [Select] <?php ini_set("soap.wsdl_cache_enabled", "0"); $url = "some.wsdl"; //$url = "http://ws.some.com/services/some?wsdl"; $soap = new SoapClient($url, array('trace' => true)); // try 3 times to login for($i = 0; $i < 3; $i++){ try{ $result = $soap->opLogin(array('name' => 'username', 'cleartext' => 'password')); $token = $result->info; $token = trim(str_replace("PubAuth1=", "", $token)); // Print token echo "token - cookie:"; print($token); echo "<br>"; // Set cookie //$soap->__setCookie('PubAuth1', $token); createSession(); // Retry loopje for($i = 0; $i < 3; $i++){ try{ // This is the second call which will not authenticate.... $result2 = $soap->__soapCall("opSetUser", array("email" => "me@you.com", 'p' =>'password123')); // Print result echo "opSetUser result: "; var_dump($result2); exit; } catch(Exception $ex){ echo "opSetUser error: " . $ex->getMessage() . "<br>"; } } } catch(Exception $ex) { echo "opLogin error: " . $ex->getMessage() . "<br>"; } } ?> THanks in advance. Davy The SOAP request initialization is taking too long to execute. We have analyzed the system and application logs which suggest that the issue resides with SOAP request initialization. We are using PHP5.3 to call .net web service using SOAP. Please suggest. Hi Guys, I have this SOAP message to be parsed using SimpleXML: <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:body> <isokresponse xmlns="http://tempuri.org/"> <isokresult>1</isokresult> </isokresponse> </soap:body> </soap:envelope> Then I load the XML: $xml = simplexml_load_string($result); I assume I need to register namespace e.g. $xml->registerXPathNamespace("soap","http://schemas.xmlsoap.org/soap/envelope/"); But what's next? How do I get the value of the element isokresult? Thank you so much <?php require_once('nusoap.php'); $soap_server = 'http://www.domain.com/api/api.cfc?wsdl'; $client = new soapclient($soap_server); $client->call() $params = array('user' => 'username@domain.com', 'password' => 'PASSWORD'); $return_string = $client->call('getKey', $params); print_r($return_string); $subId = 'XXXXXX'; $params = array('keyStr' => $keyStr, 'subId' => $subId); $return_string = $client->call('getTodaySubIDStats', $params); print_r($return_string); unset($client); ?> spits out Parse error: syntax error, unexpected T_VARIABLE in /home/site82/public_html/stats.php on line 12 Line 12 is... $params = array('user' => 'username@domain.com', Doing something wrong, but don't see it. How should one retrieve a POST parameter? My $request->toArray()['html'] works, but I am sure it is not the "right way". <?php namespace App\DataPersister; use ApiPlatform\Core\DataPersister\DataPersisterInterface; use Symfony\Component\HttpFoundation\RequestStack; class ArchivePersister implements DataPersisterInterface { public function __construct(RequestStack $requestStack) { $request = $requestStack->getCurrentRequest(); syslog(LOG_ERR, '$request->getMethod(): '.$request->getMethod()); syslog(LOG_ERR, '$request->getContent(): '.$request->getContent()); syslog(LOG_ERR, '$request->request->get(html): '.$request->request->get('html')); syslog(LOG_ERR, '$request->query->get(html): '.$request->query->get('html')); syslog(LOG_ERR, '$request->get(html): '.$request->get('html')); syslog(LOG_ERR, '$request->toArray(): '.json_encode($request->toArray())); syslog(LOG_ERR, '$request->toArray()[html]: '.$request->toArray()['html']); } } output $request->getMethod(): POST $request->getContent(): {"project":"/projects/1","description":"","html":"<p>{{ project_name }}</p>"} $request->request->get(html): $request->query->get(html): $request->get(html): $request->toArray(): {"project":"\/projects\/1","description":"","html":"<p>{{ project_name }}<\/p>"} $request->toArray()[html]: <p>{{ project_name }}</p> hi all am new to this forum help me to overcome from this error Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in D:\wamp\www\quiz1\quiz1.php on line 12 Code: [Select] <?php include("contentdb.php"); $display = mysql_query("SELECT * FROM $table ORDER BY id",$db); if (!$submit) { echo "<form method=post action=$_SERVER['PHP_SELF']>"; echo "<table border=0>"; while ($row = mysql_fetch_array($display)) { $id = $row["id"]; $question = $row["question"]; $opt1 = $row["opt1"]; $opt2 = $row["opt2"]; $opt3 = $row["opt3"]; $answer = $row["answer"]; echo "<tr><td colspan=3><br><b>$question</b></td></tr>"; echo "<tr><td>$opt1 <input type=radio name=q$id value=\"$opt1\"></td><td>$opt2 <input type=radio name=q$id value=\"$opt2\"></td><td>$opt3 <input type=radio name=q$id value=\"$opt3\"></td></tr>"; } echo "</table>"; echo "<input type='submit' value='See how you did' name='submit'>"; echo "</form>"; } elseif ($submit) { $score = 0; $total = mysql_num_rows($display); while ($result = mysql_fetch_array($display)) { $answer = $result["answer"]; $q = $result["q"]; if ($$q == $answer) { $score++; } } echo "<p align=center><b>You scored $score out of $total</b></p>"; echo "<p>"; if ($score == $total) { echo "Congratulations! You got every question right!"; } elseif ($score/$total < 0.34) { echo "Oh dear. Not the best score, but don't worry, it's only a quiz."; } elseif ($score/$total > 0.67) { echo "Well done! You certainly know your stuff."; } else { echo "Not bad - but there were a few that caught you out!"; } echo "</p>"; echo "<p>Here are the answers:"; echo "<table border=0>"; $display = mysql_query("SELECT * FROM $table ORDER BY id",$db); while ($row = mysql_fetch_array($display)) { $question = $row["question"]; $answer = $row["answer"]; $q = $row["q"]; echo "<tr><td><br>$question</td></tr>"; if ($$q == $answer) { echo "<tr><td>»you answered ${$q}, which is correct</td></tr>"; } elseif ($$q == "") { echo "<tr><td>»you didn't select an answer. The answer is $answer</td></tr>"; } else { echo "<tr><td>»you answered ${$q}. The answer is $answer</td></tr>"; } } echo "</table></p>"; } ?> thanks in adavance Hello I have one problem with fwrite() I have one script to get width and height from javascript and echo it with PHP. echo "Screen width is: ". $_GET['width'] ."<br />\n"; echo "Screen height is: ". $_GET['height'] ."<br />\n"; It works but i want to store the result in a file fwrite($info,"Height: $_GET['height'] <br />"); But then I get error Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING //////////////////////// it would be even better if I don't have to print the values but directly store them in $iinfo sorry if something similar was soved but those examples were different or i was unable to transform it to solve my problem I am trying to put a href on a line to link me to another php module, but get an error: Parse error: parse error in C:\wamp\www\editpolicy.php on line 47 My code: while ($row2 = mysql_fetch_array($result2) ) { print "<tr><td>"; <a href='editpayment.php?payid=$row2[PaymentID]'>$row2[PaymentID]</a> .........THIS IS LINE 47 ??? print "</td><td>"; print $row2['Actioned']; print "</td><td align='right'>"; print $row2['PremiumPaidAmount']; print "</td><td align='right'>"; print $row2['Risk']; print "</td></tr>"; } Ok, so I need to send a SOAP message to my server, but I have never done this before. The complete SOAP message should be as follows: Code: [Select] <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance"> <soapenv:Body><request><username>testuser</username> </request></soapenv:Body></soapenv:Envelope>I have been trying to get this to work for a while now and can't do it, so I need your help. Here is what I have right now: Code: [Select] $params = array('username'=>$username); $params2 = array('request'=>$params); $response = $client->invokeService($params2); var_dump($response); Please, any help is appreciated. I really don't understand this at all. I need help ASAP. I am trying to connect to ASC web service to do queries, however nothing seems to work. This is was i started with just to test and I am getting nothing also attached are the instructions I was provided: <?php $asc = new SoapClient('https://www.asc.gov/wsvc/ASCQuerySvc.asmx'); return $asc->GetQueryableFields(); ?> Any help would be appreciated. I would like to connect to web service (I have url to wsdl), which is protected with SSL (I have certificate and password). I would like to do that in PHP - the only solution I know is using Soap, but there is no working reference on Google that does that. I only found erros (could not resolve host, could not parse wsdl and forbiden) but no solutions. Is there any posible way to do this?
One of many attempts is like this:
<?php $wsdl = "https://url-to/test.wsdl"; $local_cert = 'cert.pem'; $passphrase = 'key'; $soapClient = new SoapClient($wsdl, array('local_cert'=> $local_cert,'passphrase'=>$passphrase)); $theResponse = $soapClient->getCertificateInfo('','',''); ?> <html><head></head><body>stdClass Object ( [DealerSearchResult] => stdClass Object ( [any] => <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet"><xs:element name="NewDataSet" msdata:isdataset="true" msdata:maindatatable="Dealer" msdata:usecurrentlocale="true"><xs:complextype><xs:choice minoccurs="0" maxoccurs="unbounded"><xs:element name="Dealer"><xs:complextype><xs:sequence><xs:element name="DealerID" type="xs:int" minoccurs="0"><xs:element name="TaxPayerNumber" type="xs:string" minoccurs="0"><xs:element name="LastName" type="xs:string" minoccurs="0"><xs:element name="Firstname" type="xs:string" minoccurs="0"><xs:element name="MiddleInitial" type="xs:string" minoccurs="0"><xs:element name="CompanyName" type="xs:string" minoccurs="0"><xs:element name="ShipAddress1" type="xs:string" minoccurs="0"><xs:element name="ShipAddress2" type="xs:string" minoccurs="0"><xs:element name="ShipCity" type="xs:string" minoccurs="0"><xs:element name="ShipState" type="xs:string" minoccurs="0"><xs:element name="ShipZip" type="xs:string" minoccurs="0"><xs:element name="ShipCountry" type="xs:string" minoccurs="0"><xs:element name="MailAddress1" type="xs:string" minoccurs="0"><xs:element name="MailAddress2" type="xs:string" minoccurs="0"><xs:element name="MailCity" type="xs:string" minoccurs="0"><xs:element name="MailState" type="xs:string" minoccurs="0"><xs:element name="MailZip" type="xs:string" minoccurs="0"><xs:element name="MailCountry" type="xs:string" minoccurs="0"><xs:element name="WorkPhone" type="xs:string" minoccurs="0"><xs:element name="HomePhone" type="xs:string" minoccurs="0"><xs:element name="FaxPhone" type="xs:string" minoccurs="0"><xs:element name="CellPhone" type="xs:string" minoccurs="0"><xs:element name="EnrollDate" type="xs:dateTime" minoccurs="0"><xs:element name="EmailPrimary" type="xs:string" minoccurs="0"><xs:element name="EmailSecondary" type="xs:string" minoccurs="0"><xs:element name="BirthDate" type="xs:dateTime" minoccurs="0"><xs:element name="Password" type="xs:string" minoccurs="0"><xs:element name="Account" type="xs:string" minoccurs="0"><xs:element name="SubAccount" type="xs:string" minoccurs="0"><xs:element name="Active" type="xs:short" minoccurs="0"><xs:element name="Deleted" type="xs:short" minoccurs="0"><xs:element name="DeleteDate" type="xs:dateTime" minoccurs="0"><xs:element name="DeleteBy" type="xs:string" minoccurs="0"><xs:element name="DealerURL" type="xs:string" minoccurs="0"><xs:element name="IsSentinal" type="xs:short" minoccurs="0"><xs:element name="TaxExempt" type="xs:short" minoccurs="0"><xs:element name="WebPhoto" type="xs:base64Binary" minoccurs="0"><xs:element name="WebGreeting" type="xs:string" minoccurs="0"><xs:element name="WebCatalogueID" type="xs:int" minoccurs="0"><xs:element name="WebProductID" type="xs:int" minoccurs="0"><xs:element name="NPO" type="xs:short" minoccurs="0"><xs:element name="IsCustomer" type="xs:short" minoccurs="0"><xs:element name="SponsoringDealerID" type="xs:int" minoccurs="0"><xs:element name="CurrencyTypeID" type="xs:int" minoccurs="0"><xs:element name="OldID" type="xs:string" minoccurs="0"><xs:element name="APPlacementDealerID" type="xs:int" minoccurs="0"><xs:element name="APDealershipNumber" type="xs:int" minoccurs="0"><xs:element name="APLineage" type="xs:string" minoccurs="0"><xs:element name="EmailOptOutUpline" type="xs:short" minoccurs="0"><xs:element name="EmailOptOutGlobal" type="xs:short" minoccurs="0"><xs:element name="EMailFormatTextOnly" type="xs:short" minoccurs="0"><xs:element name="DealerStatusCodeID" type="xs:int" minoccurs="0"><xs:element name="DateEmailPrimaryLastValidated" type="xs:dateTime" minoccurs="0"><xs:element name="EmailPrimaryValidated" type="xs:short" minoccurs="0"><xs:element name="EmailPrimaryValidationResult" type="xs:string" minoccurs="0"><xs:element name="DEFSponsorDealerID" type="xs:int" minoccurs="0"><xs:element name="DEFSponsorDealershipNumber" type="xs:int" minoccurs="0"><xs:element name="CustomerTypeID" type="xs:int" minoccurs="0"><xs:element name="DateExported" type="xs:dateTime" minoccurs="0"><xs:element name="AllowWebAccess" type="xs:short" minoccurs="0"><xs:element name="UseEWalletOnly" type="xs:int" minoccurs="0"><xs:element name="AffiliateSponsoringDealerID" type="xs:int" minoccurs="0"><xs:element name="SMSTextOptOut" type="xs:short" minoccurs="0"><xs:element name="SMSTextOnEnroll" type="xs:short" minoccurs="0"><xs:element name="SMSTextOnOrder" type="xs:short" minoccurs="0"><xs:element name="SMSTextInfoAlerts" type="xs:short" minoccurs="0"><xs:element name="CustomerStatusID" type="xs:int" minoccurs="0"><xs:element name="PayCurrencyTypeID" type="xs:int" minoccurs="0"><xs:element name="FullName" type="xs:string" minoccurs="0"></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:sequence></xs:complextype></xs:element></xs:choice></xs:complextype></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><documentelement xmlns=""><dealer diffgr:id="Dealer1" msdata:roworder="0"><dealerid>813242</dealerid><taxpayernumber>1</taxpayernumber><lastname>name</lastname><firstname>test</firstname><middleinitial><companyname>test company</companyname><shipaddress1>test address1 </shipaddress1><shipaddress2>test address 2</shipaddress2><shipcity>test city</shipcity><shipstate>N/A</shipstate><shipzip>tf1 7yl</shipzip><shipcountry>UK</shipcountry><mailaddress1>test address1 </mailaddress1><mailaddress2>test address 2</mailaddress2><mailcity>test city</mailcity><mailstate>N/A</mailstate><mailzip>tf1 7yl</mailzip><mailcountry>UK</mailcountry><workphone>01952 000 000</workphone><homephone><faxphone><cellphone><enrolldate>2014-06-03T00:00:00-05:00</enrolldate><emailprimary>test@test.com</emailprimary><emailsecondary><password>password</password><account>1</account><subaccount>0</subaccount><active>-1</active><deleted>0</deleted><dealerurl>testname</dealerurl><issentinal>0</issentinal><taxexempt>0</taxexempt><webcatalogueid>-1</webcatalogueid><webproductid>-1</webproductid><npo>0</npo><iscustomer>0</iscustomer><sponsoringdealerid>-1</sponsoringdealerid><oldid><emailoptoutupline>0</emailoptoutupline><emailoptoutglobal>0</emailoptoutglobal><emailformattextonly>0</emailformattextonly><emailprimaryvalidated>0</emailprimaryvalidated><customertypeid>0</customertypeid><allowwebaccess>-1</allowwebaccess><useewalletonly>0</useewalletonly><affiliatesponsoringdealerid>0</affiliatesponsoringdealerid><smstextoptout>-1</smstextoptout><smstextonenroll>0</smstextonenroll><smstextonorder>0</smstextonorder><smstextinfoalerts>0</smstextinfoalerts><customerstatusid>-1</customerstatusid><paycurrencytypeid>-1</paycurrencytypeid><fullname>test company</fullname></oldid></emailsecondary></cellphone></faxphone></homephone></middleinitial></dealer></documentelement></diffgr:diffgram> ) ) </body></html>this is the soap response i get from $client = new SoapClient("http://#########/WebServices/#####DealerWS.asmx?wsdl"); $result = $client->DealerSearch($params); print_r($result);bascly i want to take from this the info inside and use it as a object so i end up with $obj->LastName etc etc the diffgramm xml is the stuff i want, i can do it but manullly cuting out shcema xml $test = simplexml_load_string($result); $object = $test->DocumentElement->Dealer; echo $object->LastName; echo "<br>"; echo $object->CompanyName;but thats only when i use diffgram xml and as you can see the soap respone dose not work and throws extra content error if i try get it right so im doing it totally wrong can some one help me get it working with the response i supplyed and allow me use valuse like so i want above OK guys, I'm working on a project that involves a SOAP api. I only have reference to the method list here - http://www.ilinc.com/pdf/documentation/ilinc-web-services.pdf . basically, I got it so that I assume it's connecting fine but no matter what I do I can't get a response. I'm assuming I'm having an Issue traversing the response XML but I don't even know how to test that. here's my code... $wsdl_url = 'http://webservice.ilinc.com/perl/ilinc/api/webservice/ilinc-api.pl?WSDL'; $client = new SOAPClient($wsdl_url); $options = array('APIVersion'=>'10.0','ClientID'=>'132449','AuthorizedUserName'=>'lwilliams@biosoteria.com','AuthorizedPassword'=>'*******'); $var = array('UserID'=>'lwilliams@biosoteria.com'); $testUser = $client->GetUserID($options,array('parameters'=>$var)); print $testUser; print $testUser->return->ErrorStr; print $testUser->return->ErrorID; Now in the above code, if I do print $testUser i get this response "Catchable fatal error: Object of class stdClass could not be converted to string in /home/content/12/5907812/html/SOAP_test2.php on line 7". the other two prints return nothing. here's a snippet of the example resonse for the GetUserID method <?xml version="1.0" ?> <iLinc:Response version="10.0" xmlns:iLinc="http://www.ilinc.com"> <iLinc:GetUserIDResponse Reference="reference"> <ErrorID>error-id</ErrorID> <ErrorStr>error-str</ErrorStr> <UserID>user-id</UserID> <EncryptedUserID>encrypted-user-id</EncryptedUserID> </iLinc:GetUserIDResponse> </iLinc:Response> Can anyone tell me what I'm doing wrong? 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 Code: [Select] 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> Code: [Select] 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: Code: [Select] 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! |