PHP - Still More Help Needed With Soap Client
Well, I'm trying to connect to this webservice but not getting any useful data returned.
My code is as follows: <?php // Connect to agwebservice/AgemniLogin $agLogURL = "https://www.agemni.com/_snet/AgemniLogin.asmx?WSDL"; $myLogin->dn = "myDN"; $myLogin->username = "myUserName"; $myLogin->password = "myPassword"; $agLogin = new SoapClient($agLogURL); $agLoginResults = $agLogin->aglogin($myLogin); echo '<h2> AgemniLogin Connection: </h2>'; echo '<p style="color:red"> $agLogin { soap client - agemni session login } </p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agLogin); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agLogin); echo '<hr>'; // get cookie information from $agLogin session $agCookie = $agLogin->_cookies; echo '<p style="color:red"> $agCookie = $agLogin->_cookies</p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agCookie); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agCookie); echo '<hr>'; $agSession = $agCookie[AGSESSION]; echo '<p style="color:red"> $agSession = $agCookie[AGSESSION]</p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agSession); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agSession); echo '<p style="color:green"> $agSession[0] = '; echo $agSession[0]; echo '</p>'; echo '<p style="color:green"> $agSession[1] = '; echo $agSession[1]; echo '</p>'; echo '<p style="color:green"> $agSession[2] = '; echo $agSession[2]; echo '</p>'; echo '<hr>'; // now connect to agwebservice/ADBAccess echo '<h2> Connect to Agemni Data Access Service ADBAccess</h2>'; $agDataURL = "http://www.agemni.com/_anet/ADBAccess.asmx?WSDL"; $agDataClient = new SoapClient($agDataURL); echo '<p style="color:red"> $agDataClient { soap client - agemni Data Connection } </p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agDataClient); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agDataClient); echo '<hr>'; // set cookie information for $agDataClient echo '<p style="color:green"> try setting cookies - $agDataClient->_cookies = $agCookie </p>'; $agDataClient->_cookies = $agCookie; echo '<p style="color:green"> then look at contents of $agDataClient again </p>'; echo '<p style="color:red"> $agDataClient { soap client - agemni Data Connection } </p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agDataClient); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agDataClient); echo '<hr>'; echo '<p style="color:red"> $agDataSet = $agDataClient->getCMSData($agDataParams) </p>' ; $agDataParams->opName = 'appointment'; $agDataParams->startDate = '12/29/2010 12:01:00 AM'; $agDataParams->endDate = '12/29/2010 4:00:00 PM'; $agDataSet = $agDataClient->getCMSData($agDataParams); echo '<p style="color:blue"> print_r($agDataSet) </p>'; print_r($agDataSet); echo '<p style="color:blue"> var_dump($agDataSet) </p>'; var_dump($agDataSet); echo '<hr>'; $agDataResult = $agDataSet->getCMSDataResult; echo '<p style="color:red"> $agDataResult = $agDataSet->getCMSDataReult </p>'; echo '<p style="color:blue"> print_r($agDataResult)</p>'; print_r($agDataResult); echo '<p style="color:blue"> var_dump($agDataResult)</p>'; var_dump($agDataResult); echo '<hr>'; // do var_dump of $agLogin->__getLastResponse echo '<p style="color:green"> var_dump($agLogin->__getLastResponse()) </p>'; var_dump($agLogin->__getLastResponse()); // do var_dump of $agDataClient->__getLastResponse echo '<p style="color:green"> var_dump($agDataClient->__getLastResponse()) </p>'; var_dump($agDataClient->__getLastResponse()); ?> Below you will find the resulting output: AgemniLogin Connection: $agLogin { soap client - agemni session login } print_r: SoapClient Object ( [_soap_version] => 1 [sdl] => Resource id #4 [httpsocket] => Resource id #5 [_use_proxy] => 0 [httpurl] => Resource id #6 [_cookies] => Array ( [AGSESSION] => Array ( => AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== [1] => / [2] => www.agemni.com ) ) ) var_dump: object(SoapClient)#2 (6) { ["_soap_version"]=> int(1) ["sdl"]=> resource(4) of type (Unknown) ["httpsocket"]=> resource(5) of type (stream) ["_use_proxy"]=> int(0) ["httpurl"]=> resource(6) of type (Unknown) ["_cookies"]=> array(1) { ["AGSESSION"]=> array(3) { => string(56) "AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A==" [1]=> string(1) "/" [2]=> string(14) "www.agemni.com" } } } $agCookie = $agLogin->_cookies print_r: Array ( [AGSESSION] => Array ( => AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== [1] => / [2] => www.agemni.com ) ) var_dump: array(1) { ["AGSESSION"]=> array(3) { => string(56) "AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A==" [1]=> string(1) "/" [2]=> string(14) "www.agemni.com" } } $agSession = $agCookie[AGSESSION] print_r: Array ( => AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== [1] => / [2] => www.agemni.com ) var_dump: array(3) { => string(56) "AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A==" [1]=> string(1) "/" [2]=> string(14) "www.agemni.com" } $agSession[0] = AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== $agSession[1] = / $agSession[2] = www.agemni.com Connect to Agemni Data Access Service ADBAccess $agDataClient { soap client - agemni Data Connection } print_r: SoapClient Object ( [_soap_version] => 1 [sdl] => Resource id #9 ) var_dump: object(SoapClient)#5 (2) { ["_soap_version"]=> int(1) ["sdl"]=> resource(9) of type (Unknown) } try setting cookies - $agDataClient->_cookies = $agCookie then look at contents of $agDataClient again $agDataClient { soap client - agemni Data Connection } print_r: SoapClient Object ( [_soap_version] => 1 [sdl] => Resource id #9 [_cookies] => Array ( [AGSESSION] => Array ( => AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== [1] => / [2] => www.agemni.com ) ) ) var_dump: object(SoapClient)#5 (3) { ["_soap_version"]=> int(1) ["sdl"]=> resource(9) of type (Unknown) ["_cookies"]=> array(1) { ["AGSESSION"]=> array(3) { => string(56) "AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A==" [1]=> string(1) "/" [2]=> string(14) "www.agemni.com" } } } $agDataSet = $agDataClient->getCMSData($agDataParams) print_r($agDataSet) stdClass Object ( [getCMSDataResult] => stdClass Object ( [any] => 12/29/2010 12:01:00 AM12/29/2010 4:00:00 PM ) ) var_dump($agDataSet) object(stdClass)#7 (1) { ["getCMSDataResult"]=> object(stdClass)#8 (1) { ["any"]=> string(296) "12/29/2010 12:01:00 AM12/29/2010 4:00:00 PM" } } $agDataResult = $agDataSet->getCMSDataReult print_r($agDataResult) stdClass Object ( [any] => 12/29/2010 12:01:00 AM12/29/2010 4:00:00 PM ) var_dump($agDataResult) object(stdClass)#8 (1) { ["any"]=> string(296) "12/29/2010 12:01:00 AM12/29/2010 4:00:00 PM" } var_dump($agLogin->__getLastResponse()) NULL var_dump($agDataClient->__getLastResponse()) NULL it should be returning data somewhere in $agDataSet or $agDataResult, but there is no data except what I submitted. I'm not certain I'm setting the cookies right, or what I might be doing wrong here. Again, the documentation for their webservice is he http://wiki.agemni.com/Getting_Started/APIs/Agemni_CMS_Sync Near the bottom is an example of how to access the service using vb.net and at the bottom is an example given in Python. Not sure if they provide any additional insight, I don't do python or VB.Net so they are little help to me. Any help would be greatly appreciated. Similar TutorialsHi everyone, I've been trying to find a decent SOAP client library for PHP. The problem with PHPs own SoapClient is that it's very basic and doesn't really have support for different namespaces and headers with namespaces. It doesn't have the option to make custom attributes on soap headers or params. It can't make nested headers with SoapVars or Params and so on. Same goes to Zends SoapClient which is basicly just a wrapper for PHPs SoapClient. Is there any good client library that could handle all this stuff? I'm trying to access webservices using PHP's soap. Here's my code: <?php // test connection to agwebservice $agLogURL = "https://www.agemni.com/_snet/AgemniLogin.asmx?WSDL"; $agDN = "myDN"; $agUserName = "myUserName"; $agPass = "myPassword"; $login = new SoapClient($agLogURL); $login->aglogin($agDN, $agUserName, $agPass); // $login.service.agLogin($agDN, $agUserName, $agPass); ?> When I run the script, here's the resulting error: Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at AgemniLogin.agLogin(String dn, String username, String password) --- End of inner exception stack trace --- in C:\XAMPP\xampp\htdocs\agsync\syncwork.php:12 Stack trace: #0 [internal function]: SoapClient->__call('aglogin', Array) #1 C:\XAMPP\xampp\htdocs\agsync\syncwork.php(12): SoapClient->aglogin('myDN', 'myUserName', 'myPassword') #2 {main} thrown in \htdocs\agsync\syncwork.php on line 12 Not sure if you'll need more info on the SOAP services, but the info is he http://wiki.agemni.com/Getting_Started/APIs/Agemni_CMS_Sync#Method_details Really could use any help anyone can offer: Hello All, I'm working with a SOAP WSDL API for the first time, i need to send off some params to the server so it returns the data i'm after, i've read the SoapClient manual and looked at a few tutorials but I can't seem to work out how to actually send the data. I have been provided a sample XML document of how the request should be formatted which I have attached. All I have worked out so far is how to run the client: Code: [Select] $client = new SoapClient($url); The request XML the server is looking for is as follows: Code: [Select] <?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ARN_ReadRQ TransactionIdentifier="f8f766bb-87c0-42c0-83d5-29416b8477b7" TimeStamp="2007-07-31T14:33:52.1051647-07:00" EchoToken="Retrieve" Version="1.0" xmlns="http://www.domain.com/"> <POS> <Source> <RequestorID ID="Username" MessagePassword="Password"/> </Source> </POS> <ReadRequests> <ReadRequest> <UniqueID ID="1020-322162" Type="14"/> </ReadRequest> </ReadRequests> </ARN_ReadRQ> </s:Body> </s:Envelope> I am under the assumption this stuff goes in an array? If so how do I format it and how do I send it across? Any help greatly appreciated, Cheers. Hello everyone. So I need to make a SOAP request to an external application written in ASP.net. We run a PHP shop, so SOAP is what they offer us as means of communication. This is the request that will give the correct response. Code: [Select] <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="http://tempuri.com" xmlns:mod="http://tempuri.com"> <soapenv:Header/> <soapenv:Body> <impl:GetRegistrationURL> <impl:principal> <mod:password>__password__</mod:password><!--Optional:--> <mod:signupName>__signupName__</mod:signupName><!--Optional:--> <mod:userName>__email@test.com__</mod:userName><!--Optional:--> </impl:principal> <impl:validationType>email</impl:validationType> <impl:validationId>email@test.com</impl:validationId> </impl:GetRegistrationURL> </soapenv:Body> </soapenv:Envelope> Here is what i got PHP-wise so far... it kind of works, but i get soapFault error of Credentials not supplied. My assumption is i'm just doing it wrong. PHP Code: Code: [Select] <?php $client = new SoapClient("https://tempuri/webservices/RegistrationServiceImpl?wsdl",array("trace"=> 1, "exceptions" => 0)); $params = array('validationType' => 'email', 'validationId' => 'test@email.com'); $client->__soapCall("GetRegistrationURL", array('impl'=>$params)); ?> The above code renders this XML Request: Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://tempuri.com"> <SOAP-ENV:Body> <ns1:GetRegistrationURL> <ns1:principal xsi:nil="true"/> <ns1:validationType>email</ns1:validationType> <ns1:validationId>email@test.com</ns1:validationId> </ns1:GetRegistrationURL> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Which seems to be kind of right, but not exactly as the response becomes the following: Code: [Select] <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <ns1:GetRegistrationURLResponse xmlns:ns1="http://tempuri.com"> <ns1:out> <errorCode xmlns="http://tempuri.com">101</errorCode> <errorMessage xmlns="http://tempuri.com">Credentials not supplied</errorMessage> <registrationURL xmlns="http://tempuri.com" xsi:nil="true" /> </ns1:out> </ns1:GetRegistrationURLResponse> </soap:Body> </soap:Envelope> So, basically i need help properly passing these credentials main validationType and validationId as those are the only required ones. Thanks for the help in advance! OVERVIEW: The code is about making call to the escreen web service using SOAP and Curl with client authentication required. Currently I am not getting any result only HTTP 403 and 500 errors. The call requires client authenticate cert to be on the callng site. CODE: $content = "<TicketRequest> <Version>1.0</Version> <Mode>Test</Mode> <CommitAction></CommitAction> <PartnerInfo> <UserName>xxxxxxxxxx</UserName> <Password>xxxxxxxxxxx</Password> </ PartnerInfo> <RequestorOrderID></RequestorOrderID> <CustomerIdentification> <IPAddress></IPAddress> <ClientAccount>xxxxxxxxxx</ClientAccount> <ClientSubAccount>xxxxxxxxxx</ClientSubAccount> <InternalAccount></InternalAccount> <ElectronicClientID></ElectronicClientID> </CustomerIdentification> <TicketAction> <Type></Type> <Params> <Param> <ID>4646</ID> <Value></Value> </Param> </Params> </TicketAction> </TicketRequest>"; $wsdl = "https://services.escreen.com/SingleSignOnStage/SingleSignOn.asmx"; $headers = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", // "SOAPAction: \"\"", "Content-length: ".strlen($content), ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $wsdl); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, '1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $content); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1'); //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_HTTPHEADER, array('SOAPAction: ""')); curl_setopt($ch, CURLOPT_CAPATH, '/home/pps/'); curl_setopt($ch, CURLOPT_CAINFO, '/home/pps/authority.pem'); curl_setopt($ch, CURLOPT_SSLCERT, 'PROTPLUSSOL_SSO.pem'); curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'xxxxxxxxxxxx'); $output = curl_exec($ch); // Check if any error occured if(curl_errno($ch)) { echo 'Error no : '.curl_errno($ch).' Curl error: ' . curl_error($ch); } print_r($output); QUESTIONS: 1. I need to call the RequestTicket method and pass the XML string to it. I don't know how to do it here(pass the method name to call). 2. For client authentication they gave us three certs, one root cert, one intermediate cert and a client authentication cert PROTPLUSSOL_SSOpem(it was a .pfx file). Since we are on linux we converted them to pem . In curl calls I could not find way to how to include both the root cert and the intermediate cert ,so I combined them by making a new pem file and copying the intermediate cert and them the root cert and naming it authority.pem . I am not sure whether it works or not and would like your opinion. 3. For the current code Iam getting the error Error no : 77 Curl error: error setting certificate verify locations: CAfile: /home/pps/authority.pem CApath: /home/pps/ If I disable the curl error message,I am getting blank page with page title 403 - Forbidden. Access is denied. If I comment out the CURLOPT_CAPATH and CURLOPT_CAINFO lines it gives http 500 error page with the message as content and the following at the top. > HTTP/1.1 500 Internal Server Error. Cache-Control: private Content-Type: text/html Server: Microsoft-IIS/7.5 X-AspNet-Version: 1.1.4322 X-Powered-By: ASP.NET Date: Thu, 02 Sep 2010 14:46:38 GMT Content-Length: 1208 If I comment out as above and also CURLOPT_SSLCERT and CURLOPT_SSLCERTPASSWD it gives 403 error with the message as content. So I would request you to help me out by pointing out whats wrong with the current code. Thank you. I wish to create validation rules once which are used both on the client and on the server.
For instance, I will start off with the following PHP object:
stdClass Object ( [rules] => stdClass Object ( [email] => stdClass Object ( [required] => 1 [email] => 1 [remote] => stdClass Object ( [url] => check-email.php [type] => post [data] => stdClass Object ( [username] => function() {return $( '#username' ).val();} ) ) ) ) [messages] => stdClass Object ( [email] => stdClass Object ( [required] => an email is required ) ) )When the edit page is downloaded to the client, I will include this object in some format suitable to the client. The client will then use the jQuery Validation plugin (http://jqueryvalidation.org/) along with the validation object, and client side validate the page. When the form passes client side validation and is uploaded, PHP will use the same validation object to serverside validate the form (I have this part working as desired). My question is how should I pass this data to the client? Originally, I would just use PHP to write some JavaScript. exit('var myObj='.json_encode($myObj));Note that when I json_encode the object, the value of $myObj->rules->email->remote->data->username is a string with quotes around it, however, I can easily use PHP to strip these tags before sending it to the client. As Jacques1 pointed out in http://forums.phpfre...ascript-client/, I should never ever use PHP to generate JavaScript, and should use AJAX to download the JSON directly. I tried doing the later, but found that a callback function could not be included in the JSON. Please advise on the best way to accomplish this. Thank you 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. 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! 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! 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! 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. 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? <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 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('','',''); ?> I have a project at work to create a web service, using SOAP and have been provided a WSDL file to work from. I have never created a SOAP server before and I'm having some difficulty finding a good tutorial on building a SOAP server using a WSDL file. Can anyone provide any information, guidance, or links to some good materials to get started? Preferably a step by step tutorial that builds a SOAP server, using WSDL. Thanks! 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.
in a B2B scenario http://myserver:81/star_enu/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&UserName=user&Password=password
Allows the validation of a client by card number It is returned if the card is active (if the order is placed by the method ClientByNumCard - <Activ_Card>Y</ Activ_Card >) It is returned if the client is active ( <Activ_Card >Y</Activ_Card >) In case of success, _ID data is returned XML order example:
<?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" xmlns:tns="http://platf.com/ClientUI"> <soap:Body> <tns:ClientByNumCard_Input> <tns:N_Card>123456789</tns:N_Card> </tns:ClientNumCard_Input> </soap:Body> </soap:Envelope>
Response Envelope <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns: ClientByNumCard _Output xmlns:ns="http://plaf.com/ClientUI"> <ns:Error_spcCode>0</ns:Error_spcCode> <ns:Error_spcMessage>0</ns:Error_spcMessage> <ListIo xmlns="http://www.platf.com/xml/xxx%20yyyy%20%20G%20IO"> <CartaoClienteGeral> <Activ_Card>Y</Activ_Card> <ListOfClients> <ClientMember> <ID>1-AVG-22020</ID> <N_Client>23654</N_Client> <N_ClientS>0</N_ClientS> <Activ_Client>Y</Activ_Client> <ID>130562</ID> </ ClientMember > </ListOfClients> </CartaoClienteGeral> </ListIo> </ns:ClientByNumCard_Output> </SOAP-ENV:Body> </SOAP-ENV:Envelope> any ideas how to make a simple class in php? HI everyone, I am trying to write a simple php page using an sdk. The SDK api contains all wsdl files which do all the work. There's a soap.php which has all the functions and stores the output in $response. My php page includes soap.php and a function. The function is handled by soap.php and it will get the date from the appropriate wdsl file and store it in $response. It is stored in xml format using utf-16. If I run my php page frmo console, I get the output fine. If I run it from a browser, the page is empty but if I "view source", the date is there. What do I need to do in my php page to get $response actually displayed in a browser. Thanks Gino |