7

I have this WSDL: https://secure.softwarekey.com/solo/webservices/XmlCustomerService.asmx?WSDL

I am trying to use SoapClient to send a request to the CustomerSearch method.

The code I'm using is as follows:

$url = 'https://secure.softwarekey.com/solo/webservices/XmlCustomerService.asmx?WSDL';
$client = new SoapClient($url);

$CustomerSearch = array(
    'AuthorID' => $authorID,
    'UserID' => $userID,
    'UserPassword' => $userPassword,
    'Email' => $customerEmail 
);

$xml = array('CustomerSearch' => $CustomerSearch);

$result = $client->CustomerSearch(array('xml' => $xml));

When I run the code, I get the following PHP exception:

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'any' property

I have also tried this for the XML:

$xml = "
<?xml version=\"1.0\" encoding=\"utf-8\"?> 
<CustomerSearch>
    <AuthorID>$authorID</AuthorID>
    <UserID>$userID</UserID>
    <UserPassword>$userPassword</UserPassword>
    <Email>$customerEmail</Email>
</CustomerSearch>
";

Which gives me the following results (from a print_r):

object(stdClass)#4 (1) { ["CustomerSearchResult"]=> object(stdClass)#5 (1) { ["any"]=> string(108) "-2Invalid Xml Document" } }

The documentation says that the input XML should look something like this:

<CustomerSearch>
<AuthorID></AuthorID>
<UserID></UserID>
<UserPassword></UserPassword>
<SearchField></SearchField>
<SearchField></SearchField>
<!-- ...additional SearchField elements -->
</CustomerSearch> 

I'm fairly new to Soap and I've tried messing around (passing in raw, typed out XML), and can't seem to get this to work. Any insight on what I may be doing wrong would be greatly appreciated.

7
  • hi i am also having the same issue. I tried what he(@denormalizer) suggested this </any> is the problem Exception Error! SOAP-ERROR: Encoding: object hasn't 'any' property Commented Jan 6, 2015 at 11:22
  • See the accepted answer below. Commented Jan 6, 2015 at 17:25
  • hi Axel i tried the below answer with CustomerSearchS its working but its not working with CustomerSearch because of </any> i guess its showing error . I dont know is it because of that it showing error Commented Jan 6, 2015 at 18:20
  • I recommend you open a new question with the code you are using. Be sure to include the complete code and the complete error messages you are receiving. Commented Jan 6, 2015 at 18:21
  • Solving your problem in comments on an unrelated question/answer is not really the best place to try and solve your issue. I encourage you to focus on the responses given on the question you've asked. I can't really help you as much as other whom are more experienced on this subject. Commented Jan 6, 2015 at 18:26

2 Answers 2

13

I think you need to look more into the documentation (with regards to the any parameter). But your request should be something like this:

$url = 'https://secure.softwarekey.com/solo/webservices/XmlCustomerService.asmx?WSDL';
$client = new SoapClient($url);

$xmlr = new SimpleXMLElement("<CustomerSearch></CustomerSearch>");
$xmlr->addChild('AuthorID', $authorID);
$xmlr->addChild('UserID', $userID);
$xmlr->addChild('UserPassword', $userPassword);
$xmlr->addChild('Email', $customerEmail);

$params = new stdClass();
$params->xml = $xmlr->asXML();

$result = $client->CustomerSearchS($params);

EDIT: This is how I've done it in similar project. It may not be best practice. SoapVar might be the better way to do it (SoapVoar example with ANY_XML).

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks, this let me down the right track. I updated your answer with the exact code that worked for me. I used the CustomerSearchS instead, as you can pass the XML as a string. I also used addChild to generate the correct XML format.
for me i am getting this error Exception Error! SOAP-ERROR: Encoding: object hasn't 'any' property
$client->CustomerSearch($params); when i am calling CustomerSearch tell me the reson for that
i mean what is any here
I'm not entirely sure, I asked this question over 2 years ago. If you're having an issue and the above code isn't working, I'd recommend compiling the code you are using into a new question and asking it (including all the details of what you are trying to do).
0

try passing $client->CustomerSearch($CustomerSearch); or pass a string

3 Comments

I've tried that. $client->CustomerSearch($CustomerSearch) returns an Invalid XML Document response.
$result = $client->CustomerSearch(array('xml' => 'string')); xml is defined as string
The XML isn't a string, it's an array. I've tried passing the XML as a string, I've tried passing the XML through new SoapVar(xml, XSD_STRING);$, then passing it to the Soap method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.