XML encoding issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Not quite sure what's going on here so would appreciate some help.
I'm connecting to a SOAP service and the service receives and responds
correctly to a request. I've confirmed this by looking at teh HTTP
headers flowing backwards and forwads. However, the soap class returns
a fault with the text "Error: XML error on line 1 col 4 byte 4 not
well-formed (invalid token)" I've tried various options of literal vs
document but no joy.

Any pointers appreciated.

Cheers,
Graeme


OUTGOING
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";

<SOAP-ENV:Body>
<queryTable xmlns="http://reportingapi.services.example.com";>
<query>
<expression>SHOW ACCOUNT.tables</expression>
<language>en_us</language></query></queryTable>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

INCOMING

<?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>
 <ns1:queryTableResponse xmlns:ns1="http://reportingapi.services.example.com";>
  <ns1:queryTableResult>
   <ns1:tableHeader>
    <ns1:name>ACCOUNT</ns1:name>


CODE
<?php
require_once 'SOAP/Client.php';

// lots of set up stuff
$wsdl_url =  'ReportingAPI.wsdl';

// including various client options
$WSDL     = new SOAP_WSDL($wsdl_url);
$client   = $WSDL->getProxy();
$client->setOpt('trace', 1);
$client->setEncoding('UTF-8');

// turns out you needed to make nested values
// these equate to XML tags
$query_sql =& new SOAP_Value('expression', 'string', 'SHOW ACCOUNT.tables');
$query_lang =& new SOAP_Value('language', 'string', 'en_us');
$query_packet =& new SOAP_Value('query', 'query', array($query_sql,
$query_lang));

$result = $client->queryTable(array($query_packet));

if (PEAR::isError($result)) {
   echo 'Error: ' . $result->getMessage() . "\n";
   echo $client->getWire();
} else {
  echo "Error free!";
}

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux