开发者

PHP soap server double encoding html strings

I'm having a problem where my php soap webservice is double encoding strings. For example if I try to return the string O'Test, what I get is O'Test. What I would have expected to see is O'Test. It seems like what is happening is the & itself is getting encoded?

I've look through what phpinfo() returns (this is php version 5.1.6), but I don't see anything obvious.

My code to initialize the soap server uses arrays to automate the initialization of my functions and types but this is the gist of what I'm doing:

$server = new soap_server();

$server->configureWSDL('server', 'urn:sg');

$server->wsdl->addComplexType( 'testCall', 'complexType', 'struct', 'all', '', array( 'name' => 'testName', 'type' => 'xsd:string' ) );

$server->register( $fname,
array( 'request' => 'tns:TestCallRequest' ),
array( 'return' => 'tns:TestCallResponse' ),
'urn:sg',
'urn:sg#testCall' );

$server->service($HTTP_RAW_POST_DATA);

Here is the function represented by $fname above:

function testCall() {
    $result = array();

    $result[testName] = 'O\'Test';

    return $result;
}

Here is the soap request and response that I see from a client perspective:

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sg"><soapenv:Header/><soapenv:Body><urn:testCall soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><urn:TestCallRequest></urn:TestCallRequest></urn:testCall></soapenv:Body></soapenv:Envelope>

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 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/" xmlns:tns="urn:sg"><SOAP-ENV:Body><ns1:TestCallResponse xmlns:ns1="urn:sg"><return xsi:type="tns:TestCallResponse"><testName xsi:type="xsd:string">O&amp;apos;Test</testName></return></ns1:Test开发者_如何学GoCallResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜