0

I'm trying to send user registrations with soap to another server. I'm creating an xml with DOMdocument and than after saveXML I'm running the soap which should return an xml with registration id plus all the data I sent in my xml. But the Soap returns unknown error. exactly this: stdClass Object ( [RegisztracioInsResult] => stdClass Object ( [any] => 5Unknown error ) )

and this is how I send my xml.

/*xml creation with DOMdocument*/
$xml = saveXML();
$url = 'http://mx.biopont.com/services/Vision.asmx?wsdl';
$trace = '1';
$client = new SoapClient($url, array('trace' => $trace, "exceptions" => 0, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
$params = $client->RegisztracioIns(array('xml' => $xml));
$print_r($params);

If I click on the description of the RegisztracioIns service at this URL http://mx.biopont.com/services/Vision.asmx it shows me this:

POST /services/Vision.asmx HTTP/1.1
Host: mx.biopont.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://mx.biopont.com/services/RegisztracioIns"

<?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>
    <RegisztracioIns xmlns="http://mx.biopont.com/services/">
      <xml>string</xml>
    </RegisztracioIns>
  </soap:Body>
</soap:Envelope>

According to this I think I'm doing the upload correctly but maybe not I don't have much experience with soap.

Is there anything I'm missing? I also tried to save the xml to my server an than get the contents with file_get_contents(). but the result was the same.

Laci K
  • 585
  • 2
  • 8
  • 24

1 Answers1

0

You should be able to do something like this:

$res = $client->__soapCall( 'RegisztracioIns', array('xml'=>'my string to send'));

To have the wsdl wrap 'my string to send' in the proper tags.

You are doing something similar, but I dont think the wsdl is actually wrapping the string you are trying to pass, and passing nothing instead, resulting in unknown error.

You can examine the outgoing xml using $client->__getLastRequest();.

(Also, you have a small typo in your code on the last line should be print_r($params);.)

Failing that you could try to write the xml yourself using SoapVar() and setting the type to XSD_ANYXML.

It seems cleaner to me when the wsdl wraps everything for you, but its better than banging your head against the wall until it does.

I made an attempt to do just that with your wsdl. Give this a try:

$wsdl = "http://mx.biopont.com/services/Vision.asmx?wsdl"; 
$client = new SoapClient($wsdl, array(  'soap_version' => SOAP_1_1,
                                    'trace' => true,
                                    )); 
try {

$xml = "<RegisztracioIns xmlns='http://mx.biopont.com/services/'>
            <xml>string</xml>
        </RegisztracioIns>";

$args= array(new SoapVar($xml, XSD_ANYXML)); 

$res = $client->__soapCall( 'RegisztracioIns', $args );
var_dump($res);

} catch (SoapFault $e) {

echo "Error: {$e}";

}
print_r($client->__getLastRequest());
print_r($client->__getLastResponse());

I can't exactly read the response I am getting with that given that it is Hungarian (I think?). So let me know if that works for you.

Community
  • 1
  • 1
quaspas
  • 1,351
  • 9
  • 17