nymets1104 Posted July 21, 2015 Share Posted July 21, 2015 I have been using PEAR SOAP with an API that supports SOAP for several years. One a new call I am trying to implement, the request is required to be in this format: <CartItems> <CartItem> <Quantity>1</Quantity> <Item xsi:type="Service"> <ID>000123</ID> </Item> </CartItem> </CartItems> <Payments> <PaymentInfo xsi:type="CreditCardInfo"> <CreditCardNumber>{CreditCardNumber}</CreditCardNumber> <Amount>5</Amount> <BillingAddress>123 Happy Ln</BillingAddress> <BillingCity>San Luis Obispo</BillingCity> <BillingState>CA</BillingState> <BillingPostalCode>93405</BillingPostalCode> <ExpYear>2014</ExpYear> <ExpMonth>7</ExpMonth> <BillingName>Bob Joe</BillingName> </PaymentInfo> </Payments> The main issues are with: <Item xsi:type="Service"> AND <PaymentInfo xsi:type="CreditCardInfo"> With traditional PHP SOAP I Would use the following code for the request: $checkoutShoppingCartRequest = $mb->CheckoutShoppingCart(array( 'Test'=>'true', 'ClientID'=>1234, 'CartItems'=>array( 'CartItem'=>array( 'Quantity'=>1, 'Item' => new SoapVar( array('ID'=>'1357'), SOAP_ENC_ARRAY, 'Service', 'http://clients.mindbodyonline.com/api/0_5' ), 'DiscountAmount' => 0 ) ), 'Payments' => array( 'PaymentInfo' => new SoapVar( array( 'CreditCardNumber'=>'4111111111111111', 'ExpYear'=>'2015', 'ExpMonth'=>'06', 'Amount'=>'130', 'BillingAddress'=>'123 Happy Ln', 'BillingPostalCode'=>'93405' ), SOAP_ENC_ARRAY, 'CreditCardInfo', 'http://clients.mindbodyonline.com/api/0_5' ) ) )); This does not seem to work with PEAR SOAP, in fact anything involving the SoapVar kills the request and nothing is sent. Any statements or even an echo "HELLO" below the SoapVar are not touched when I load the page. I have found very limited documention on this. Does anyone know the proper way to form this request with PEAR SOAP? Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/ Share on other sites More sharing options...
nymets1104 Posted July 21, 2015 Author Share Posted July 21, 2015 (edited) Is this thread hidden? I noticed it has 0 views in 12 hours? Edit: Hmm, now it suddenly has 39 views. Guess I needed to refresh Edited July 21, 2015 by nymets1104 Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517021 Share on other sites More sharing options...
nymets1104 Posted July 21, 2015 Author Share Posted July 21, 2015 (edited) Once I enabled Error Reporting I am getting these Errors: Notice: Undefined property: stdClass::$PaymentInfo in /hermes/waloraweb019/b71/moo.studiosevacom/saleOYC.php on line 35 Fatal error: Class 'SoapVar' not found in /hermes/waloraweb019/b71/moo.studiosevacom/saleOYC.php on line 35 I am running PEAR SOAP on Fatcow with PHP 5.3 Edited July 21, 2015 by nymets1104 Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517024 Share on other sites More sharing options...
requinix Posted July 21, 2015 Share Posted July 21, 2015 Not many people are familiar with SOAP. Are you sure SOAP is installed at all? And why are you using PEAR for it? And why are you still on PHP 5.3? Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517025 Share on other sites More sharing options...
nymets1104 Posted July 21, 2015 Author Share Posted July 21, 2015 Not many people are familiar with SOAP. Are you sure SOAP is installed at all? And why are you using PEAR for it? And why are you still on PHP 5.3? Unfortunately Fatcow's shared hosting is very limited as far as PHP: http://www.fatcow.com/knowledgebase/beta/article.bml?ArticleID=2124 SOAP is installed as I can make calls to this API that do not contain the XSI:TYPE tag (<Item xsi:type="Service">) Fatcow does not support PHP SOAP only PEAR SOAP which seems to be a huge hurdle. Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517026 Share on other sites More sharing options...
requinix Posted July 21, 2015 Share Posted July 21, 2015 PHP 5.3 has been entirely unsupported for almost a year now. Even 5.4 is only receiving security fixes. Their inability to keep up with changing times is worrisome. PEAR's SOAP is not the same as the bundled version. For one, it doesn't have the SoapVar class which is why you're getting that fatal error. There is a SOAP_Value which sounds equivalent, but it's not identical. Maybe 'Item' => new SOAP_Value( 'Item', // name 'Service', // type array('ID'=>'1357') // value ), Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517036 Share on other sites More sharing options...
nymets1104 Posted July 22, 2015 Author Share Posted July 22, 2015 PHP 5.3 has been entirely unsupported for almost a year now. Even 5.4 is only receiving security fixes. Their inability to keep up with changing times is worrisome. PEAR's SOAP is not the same as the bundled version. For one, it doesn't have the SoapVar class which is why you're getting that fatal error. There is a SOAP_Value which sounds equivalent, but it's not identical. Maybe 'Item' => new SOAP_Value( 'Item', // name 'Service', // type array('ID'=>'1357') // value ), Thank You very much for your input. I believe that these limitations from PEAR will ultimately make it impossible to accomplish this call successfully. I did try the Soap_Value suggestion and while it did fix the Fatal Errors, the End Point doesnt seem to recognize it as a valid request. [CartItems] => Array ( [0] => Array ( [Quantity] => 1 [Item] => SOAP_Value Object ( [value] => Array ( [ID] => 1357 ) [nqn] => QName Object ( [name] => Item [prefix] => [namespace] => ) [name] => Item [namespace] => [tqn] => QName Object ( [name] => Service [prefix] => [namespace] => ) [type] => Service [type_namespace] => [arrayType] => [attributes] => Array ( ) [options] => Array ( ) ) ) ) [Payments] => Array ( [0] => Array ( [PaymentInfo] => SOAP_Value Object ( [value] => Array ( [CreditCardNumber] => 4111111111111111 [ExpYear] => 2015 [ExpMonth] => 06 [Amount] => 130 [BillingAddress] => 123 Happy Ln [BillingPostalCode] => 93405 ) [nqn] => QName Object ( [name] => PaymentInfo [prefix] => [namespace] => ) [name] => PaymentInfo [namespace] => [tqn] => QName Object ( [name] => CreditCardInfo [prefix] => [namespace] => ) [type] => CreditCardInfo [type_namespace] => [arrayType] => [attributes] => Array ( ) [options] => Array ( ) ) ) ) ) object(stdClass)#13 (7) { ["Status"]=> string(17) "InvalidParameters" ["ErrorCode"]=> string(4) "9999" ["Message"]=> string(55) "The cart must have at least one payment method defined." ["XMLDetail"]=> string(4) "Full" ["ResultCount"]=> string(1) "0" ["CurrentPageIndex"]=> string(1) "0" ["TotalPageCount"]=> string(1) "0" } I can start another thread for this, but rather than relocating my website to a Server that supports a more recent and robust PHP Library, would it be possible for me to utililize an external server for these requests while allowing me to keep my site with Fatcow? Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517045 Share on other sites More sharing options...
requinix Posted July 22, 2015 Share Posted July 22, 2015 Can you get the raw XML generated during the request? That'll make it easier to understand what's going wrong. Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517046 Share on other sites More sharing options...
nymets1104 Posted July 22, 2015 Author Share Posted July 22, 2015 So I tried capturing the XML Packets with Wireshark on this SOAP Request and even on other succesful Requests. I had no luck, but then it dawned on me. The XML is being sent from the Server (Fatcow) to the Web Service Endpoint (MindBody). So would it even be possible to capture this packet with wireshark or an alternate way? Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517111 Share on other sites More sharing options...
requinix Posted July 22, 2015 Share Posted July 22, 2015 Not really. Set the "trace" option, then look at SOAP_Client's $_last_request and $_last_response properties. Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517114 Share on other sites More sharing options...
nymets1104 Posted July 23, 2015 Author Share Posted July 23, 2015 (edited) Set Trace to 1 and got this response: Unable to parse WSDL file https://api.mindbodyonline.com/0_5/SaleService.asmx XML error on line 5: > required Im doing some googling as we speak... I get this same message for succesful and unsuccesful SOAP Calls Edited July 23, 2015 by nymets1104 Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517147 Share on other sites More sharing options...
requinix Posted July 23, 2015 Share Posted July 23, 2015 That URL you gave is not to a WSDL. Go to it yourself and see. Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517157 Share on other sites More sharing options...
boompa Posted July 23, 2015 Share Posted July 23, 2015 To get a valid WSDL from that location you need to append ?wsdl to the url: https://api.mindbodyonline.com/0_5/SaleService.asmx?wsdl Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517158 Share on other sites More sharing options...
nymets1104 Posted July 23, 2015 Author Share Posted July 23, 2015 To get a valid WSDL from that location you need to append ?wsdl to the url: https://api.mindbodyonline.com/0_5/SaleService.asmx?wsdl That URL you gave is not to a WSDL. Go to it yourself and see. Good Call, now I get: Request : No operation __getLastRequest for port Sale_x0020_ServiceSoap in WSDL. The Code I am using to call this is: sale_proxy.php: <?php class WebService_Sale_x0020_Service_Sale_x0020_ServiceSoap extends SOAP_Client { function WebService_Sale_x0020_Service_Sale_x0020_ServiceSoap($path = 'https://api.mindbodyonline.com/0_5/SaleService.asmx?wsdl') { $option=array('trace'=>1); $this->SOAP_Client($path,$option); } function &CheckoutShoppingCart($Request) { $CheckoutShoppingCart = new SOAP_Value('{http://clients.mindbodyonline.com/api/0_5}CheckoutShoppingCart', false, $v = array('Request' => $Request)); $result = $this->call('CheckoutShoppingCart', $v = array('CheckoutShoppingCart' => $CheckoutShoppingCart), array('namespace' => 'http://clients.mindbodyonline.com/api/0_5', 'soapaction' => 'http://clients.mindbodyonline.com/api/0_5/CheckoutShoppingCart', 'style' => 'document', 'use' => 'literal')); return $result; } sale.php: require_once 'SOAP/Client.php'; require_once 'sale_proxy.php'; $proxySales= new WebService_Sale_x0020_Service_Sale_x0020_ServiceSoap(); $ret=$proxySales->CheckoutShoppingCart($Request); // <xmp> tag displays xml output in html echo 'Request : <br/><xmp>', $proxySales->__getLastRequest(), '</xmp><br/><br/> Error Message : <br/>'; Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517161 Share on other sites More sharing options...
requinix Posted July 23, 2015 Share Posted July 23, 2015 Where's this "__getLastRequest" coming from? It's the $_last_request and $_last_response properties. As in $proxySales->_last_request Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517234 Share on other sites More sharing options...
nymets1104 Posted July 24, 2015 Author Share Posted July 24, 2015 OK I tried this: echo "Request: ".$proxySales->_last_request; and got nothing... Request: Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517314 Share on other sites More sharing options...
requinix Posted July 25, 2015 Share Posted July 25, 2015 Okay... You could try outputting the entire object, like print_r($proxySales);to see if there's something useful in there. Otherwise all I can suggest is to look through the SOAP examples to see how their code is supposed to be used. Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517339 Share on other sites More sharing options...
nymets1104 Posted July 30, 2015 Author Share Posted July 30, 2015 Okay... You could try outputting the entire object, like print_r($proxySales);to see if there's something useful in there. Otherwise all I can suggest is to look through the SOAP examples to see how their code is supposed to be used. I appreciate your help with this. Unfortunately it seems with the limitations imposed by Fatcow Hosting, I am not bale to form the request in the way that the Server handling it can interpret correctly. I briefly attempted to use Java script to run interact with the Web Service, but this caused even more problems with cross domain issues and so forth. I will continue to work through this and will post any updates here. Again, thanks for sticking with me on this frustrating situation Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1517745 Share on other sites More sharing options...
nymets1104 Posted September 18, 2015 Author Share Posted September 18, 2015 UPDATE! After migrating my entire site to a new Host with a robust support of PHP and SOAP I have successfully made calls to the API <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://clients.mindbodyonline.com/api/0_5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> <ns1:CheckoutShoppingCart> <ns1:Request> <ns1:SourceCredentials> <ns1:SourceName>YogaStudio</ns1:SourceName> <ns1:Password>***********************</ns1:Password> <ns1:SiteIDs> <ns1:int>99999</ns1:int> </ns1:SiteIDs> </ns1:SourceCredentials> <ns1:UserCredentials> <ns1:Username>username</ns1:Username> <ns1:Password>password</ns1:Password> <ns1:SiteIDs> <ns1:int>99999</ns1:int> </ns1:SiteIDs> </ns1:UserCredentials> <ns1:XMLDetail xsi:nil="true"/> <ns1:PageSize xsi:nil="true"/> <ns1:CurrentPageIndex xsi:nil="true"/> <ns1:ClientID>999</ns1:ClientID> <ns1:Test>true</ns1:Test> <ns1:CartItems> <ns1:CartItem> <ns1:Item xsi:type="ns1:Service"> <ns1:ID>77</ns1:ID> </ns1:Item> <ns1:DiscountAmount>0</ns1:DiscountAmount> <ns1:Quantity>1</ns1:Quantity> < /ns1:CartItem> </ns1:CartItems> <ns1:InStore xsi:nil="true"/> <ns1:Payments> <ns1:PaymentInfo xsi:type="ns1:CreditCardInfo"> <ns1:CreditCardNumber>9999999999999999</ns1:CreditCardNumber> <ns1:Amount>15</ns1:Amount> <ns1:ExpMonth>06</ns1:ExpMonth> <ns1:ExpYear>2015</ns1:ExpYear> <ns1:BillingAddress>123 Happy Ln</ns1:BillingAddress> <ns1:BillingPostalCode>93405</ns1:BillingPostalCode> </ns1:PaymentInfo> </ns1:Payments> <ns1:SendEmail xsi:nil="true"/> <ns1:LocationID xsi:nil="true"/> </ns1:Request> </ns1:CheckoutShoppingCart> </SOAP-ENV:Body> </SOAP-ENV:Envelope> I used this PHP to make the call: <?php ini_set('display_errors', 1); error_reporting(-1); include_once('MINDBODY_API_v0.5.php'); $mb = new MINDBODY_API(); $checkoutShoppingCartRequest = $mb->CheckoutShoppingCart(array( 'Test'=>'true', 'ClientID'=>999, 'CartItems'=>array( 'CartItem'=>array( 'Quantity'=>1, 'Item' => new SoapVar( array('ID'=>'999'), SOAP_ENC_ARRAY, 'Service', 'http://clients.mindbodyonline.com/api/0_5' ), 'DiscountAmount' => 0 ) ), 'Payments' => array( 'PaymentInfo' => new SoapVar( array( 'CreditCardNumber'=>'9999999999999999', 'ExpYear'=>'2015', 'ExpMonth'=>'06', 'Amount'=>'0', 'BillingAddress'=>'123 Happy Ln', 'BillingPostalCode'=>'93405' ), SOAP_ENC_ARRAY, 'CreditCardInfo', 'http://clients.mindbodyonline.com/api/0_5' ) ) )); ?> <textarea><?= $mb->getXMLRequest(); ?></textarea> <textarea><?= $mb->getXMLResponse(); ?></textarea> Thanks for all who commeted as it was all very helpful! Quote Link to comment https://forums.phpfreaks.com/topic/297400-using-soapvar-with-pear-soap-again/#findComment-1521058 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.