PHP - Problem With Soap Request
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 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 ...
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/>"; }
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 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 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. I am trying to use SOAP to log into and view reports from SSRS 2005 located on another server. When I run the code below, I get the error "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://[SERVER]/reportserver/ReportExecution2005.asmx?wsdl' : Premature end of data in tag HTML line 2 " PHP version 5.2.5 SOAP is enabled - I can access amazon's SOAP, so I have confirmed it works; I cannot access mine I have confirmed that this is the correct login information and url to what I want. I can put it into a browser and log in from there and get access to it, but I cannot get it through the PHP SOAPClient. Any help would be greatly appreciated. Code: [Select] <?php ini_set('soap.wsdl_cache_enabled', false); $soap_url = 'https://[SERVER]/reportserver/ReportExecution2005.asmx?wsdl'; try { $options = Array('login' => 'username', 'password' => 'password'); $soap_client = new SoapClient($soap_url, $options); var_dump($soap_client->__getFunctions()); } catch (SoapFault $e) { echo $e->getMessage(); } ?> [CODE] Hi everybody, I am working with SOAP-PEAR and run on a nasty problem I don't know answer to. First I explain what I know how to do. I am trying to construct a soap request and I know how to do this if XML has this structu Case 1 Code: [Select] <parent> <child1>string</child1> <child2>string</child2> <child3>string</child3> </parent> In this case, I construct an Array("root" => new Soap_Value("child1", "string", "value")).... Now my problem is that I don't know how to create an array() or some other data if XML structure is like this: Case 2 Code: [Select] <parent child1="value1" child2="value2" child3="value3" /> Could somebody please tell me how I can construct a SOAP request with SOAP-PEAR for that structure in Case 2? I just can't find a way to formulate it using arrays or some other data type Your help will greatly be appreciated. Thank you, Victor. I have strange problem with SOAP. My file SchoolAPI look like that: <?php require_once('../require/constants.php'); require_once('../require/connection.inc.php'); class SchoolAPI{ private $dbh; public function __construct() { $this->dbh = new PDO(DRIVER.':host='.HOST.';dbname='.DB, USER, PASSWORD); } //function return all subcjects public function getSubjects(){ $sth = $this->dbh->prepare(' SELECT id, nazwa ROM subjects'); $sth->execute(); return $sth->fetchAll(PDO::FETCH_NUM); //return array(array("1", "subject1"),array("2", "subject2")); } //function return all classes public function getClasses(){ $sth = $this->dbh->prepare(' SELECT id, nazwa FROM classes'); $sth->execute(); return $sth->fetchAll(PDO::FETCH_NUM); //return array(array("1", "class1"),array("2", "class2")); } } ini_set("soap.wsdl_cache_enabled", "0"); $server = new SoapServer("SchoolAPI.wsdl"); $server->setClass("SchoolAPI"); $server->handle(); ?> wsdl file is named SchoolAPI.wsdl and look like that: <wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schema.example.com" targetNamespace="http://schema.example.com" > <wsdl:types> <xsd:schema targetNamespace="http://schema.example.com"> <xsd:complexType name="myarry2"> <xsd:sequence> <xsd:element minOccurs="0" maxOccurs="unbounded" name="row" nillable="true" type="xsd:string" /> </xsd:sequence> </xsd:complexType> </xsd:schema> <xsd:schema targetNamespace="http://schema.example.com"> <xsd:complexType name="myarray"> <xsd:sequence> <xsd:element minOccurs="0" maxOccurs="unbounded" name="table" nillable="true" type="tns:myarry2" /> </xsd:sequence> </xsd:complexType> </xsd:schema> </wsdl:types> <wsdl:message name="getSubjectsRequest"></wsdl:message> <wsdl:message name="getSubjectsResponse"> <part name="getSubjectsReturn" type="tns:myarray"/> </wsdl:message> <wsdl:message name="getClassesRequest"></wsdl:message> <wsdl:message name="getClassesResponse"> <part name="getClassesReturn" type="tns:myarray"/> </wsdl:message> <wsdl:portType name="SchoolAPIPortType"> <wsdl:operation name="getSubjects"> <wsdl:input message="tns:getSubjectsRequest"/> <wsdl:output message="tns:getSubjectsResponse"/> </wsdl:operation> <wsdl:operation name="getClasses"> <wsdl:input message="tns:getClassesRequest"/> <wsdl:output message="tns:getClassesResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="SchoolAPIBinding" type="tns:SchoolAPIPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getSubjects"> <soap:operation soapAction="urn:SchoolAPI/getSubjects" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> <wsdl:operation name="getClasses"> <soap:operation soapAction="urn:SchoolAPI/getClasses" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="SchoolAPI"> <wsdl:port name="SchoolAPIPort" binding="tns:SchoolAPIBinding"> <soap:address location="http://localhost:82/myschool/webservices/SchoolAPI.php" /> </wsdl:port> </wsdl:service> </wsdl:definitions> The problem is that correct data is returned olny by first function declarated in <wsdl:binding> section. In this example correct data will be return by getSubjects function, and function getClassses return null. However, if we change order and put getClasses operation first in binding section like this: <wsdl:binding name="SchoolAPIBinding" type="tns:SchoolAPIPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getClasses"> <soap:operation soapAction="urn:SchoolAPI/getClasses" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> <wsdl:operation name="getSubjects"> <soap:operation soapAction="urn:SchoolAPI/getSubjects" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> </wsdl:binding> then correct data will be return by getClasses function, and getSubjects will return null. Do you know what is going on? I do my best to solve this problem and I have no idea what is wrong... 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 guys, I have been tasked with a SOAP project at work. Basically we have a database on our own internal server that holds information on our customers. This database is managed by an external company and we are able to use predefined SOAP calls that will do certain things for us. We then have a website that the general public access to update their information. I am having trouble understanding how to connect the 2 systems. The website is built in PHP. I am really looking for a proper beginners guide on how to integrate the 2. Can anyone point me in the right direction? Thanks! 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! I am completely and utterly stuck on this. I have tried about 20 different examples but nothing works. I simply want to send an XML message to a web service and receive its response. (1) The url is europaytest.smart2pay.com/MerchantService.asmx. But, does it need ?wsdl on the end?? It could be europaytest.smart2pay.com/MerchantService.asmx?wsdl ?? (2) I need to send XML to the above url using 'SubmitRequest' as the 'action' value. I would have thought this would do it: Code: [Select] $client = new SoapClient("https://europaytest.smart2pay.com/MerchantService.asmx?wsdl"); $response = $client->__doRequest($xml, "https://europaytest.smart2pay.com/MerchantService.asmx", "SubmitRequest", 1.1); But it returns with this XML response message: 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><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: SubmitRequest. at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope> 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('','',''); ?> 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. Hi guys! I started working on a project involving connecting to a soap server (windows). Eight hours later i am nowhere. The documentation is horrible and searching for error messages is a task that never ends. So now i am back here to ask all you guys :-) First of all, i want to connect to a external server which ends in: Code: [Select] GatewayWebService.asmx?WSDL So i got the variable: Code: [Select] $client = new SoapClient("http://XXXXXXXX/GatewayWebService.asmx?WSDL", array('login'=> "XXXXX",'password'=> 'XXXXXX')); And i want to do a call like: Code: [Select] print($client->RetrieveArticles("Article")); So now i get an error: Code: [Select] php webservice-import.php PHP Catchable fatal error: Object of class stdClass could not be converted to string in /var/www/vhosts/test.shoerama.nl/httpdocs/maintenance/webservice-import.php on line 11 But i dont think that all above is very correct. So i want to ask you guys for some help. How can i get a call with, lets say, the first 10 records from the soap server? How do i do soap call? I recieved the following "code" from the guys that host the soap server: Code: [Select] sXml: <Parameters><timestamp>1</timestamp><branch>98</branch><pos>1</pos><languagecode></languagecode><maxitems>100</maxitems></Parameters> What do i do with this? Thanks in advance guys! |