themistral Posted January 18, 2012 Share Posted January 18, 2012 Hiya, I was cruising along with SOAP nicely until I needed to parse more complex xml in a soapcall. I am using non-wdsl if that makes any difference. I need to create XML in the following structure: <Body> <SOAP_updateCreateContactMarketingRule> <Contact_ID xsi:type="xsd:int">1</Contact_ID> <MarketingRule_ID xsi:type="xsd:int">1</MarketingRule_ID> <MarketingQuestions> <MarketingQuestion> <MarketingQuestion_ID xsi:type="xsd:int">1</MarketingQuestion_ID> <Answer xsi:type="xsd:string">No</Answer> </MarketingQuestion> <MarketingQuestion> <MarketingQuestion_ID xsi:type="xsd:int">2</MarketingQuestion_ID> <Answer xsi:type="xsd:string">Yes</Answer> </MarketingQuestion> </MarketingQuestions> </SOAP_updateCreateContactMarketingRule> </Body> So, I set my parameters up as follows: $params[] = new SoapParam("1", "Contact_ID"); $params[] = new SoapParam("1", "MarketingRule_ID"); $params[] = new SoapParam(array("MarketingQuestion"=>array("MarketingQuestion_ID"=>1, "Answer"=>"Yes")), "MarketingQuestions"); And I am getting the following XML generated when I use __getLastRequest() <SOAP-ENV:Body> <ns1:SOAP_updateCreateContactMarketingRule> <Contact_ID xsi:type="xsd:string">1</Contact_ID> <MarketingRule_ID xsi:type="xsd:string">1</MarketingRule_ID> <MarketingQuestions SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array"> <item xsi:type="ns2:Map"> <item> <key xsi:type="xsd:string">MarketingQuestion_ID</key> <value xsi:type="xsd:int">8</value> </item> <item> <key xsi:type="xsd:string">Answer</key> <value xsi:type="xsd:string">Yes</value> </item> </item> </MarketingQuestions> </ns1:SOAP_updateCreateContactMarketingRule> </SOAP-ENV:Body> Clearly my third parameter is not set up correctly - can anyone help with this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/255272-complex-data-required-for-soapparams/ Share on other sites More sharing options...
dzelenika Posted January 18, 2012 Share Posted January 18, 2012 You need to create object instead of array! <?php class mQuestion { public MarketingQuestion_ID; public Answer } $question1 = new mQuestion(); $question2 = new mQuestion(); $question1->MarketingQuestion_ID = 1; // fill other fields ... $client->__soapCall("SomeFunction", array($question1, $question1)); ?> Quote Link to comment https://forums.phpfreaks.com/topic/255272-complex-data-required-for-soapparams/#findComment-1308878 Share on other sites More sharing options...
themistral Posted January 18, 2012 Author Share Posted January 18, 2012 Thank you dzelenika! Got it all working now - much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/255272-complex-data-required-for-soapparams/#findComment-1308914 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.