0

all I had to do was change the default charset in my php.ini file

default_charset = "UTF-8"

I'm trying to create a SOAP client in PHP, but I'm having trouble with encoding. The $Response has words with incorrect characters like è instead of è.

When importing the WSDL file into SoapUI (a soap test suite) responses come back correctly encoded, so I don't think it has to do with the SOAP service. SoapUI indicates that it's using UTF-8. I've also tried a bunch of other encodings, but without success.

All my php files are encoded in UTF-8.

$client = new SoapClient($wsdl_file, array('encoding'=>'UTF-8'));
$Response = $client->__soapCall('GetMemberDetails', array($request));
debug($Response); die;

A sample response:

<members xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <UserInfo>
    ...
    <Status>règle</Status>
    ...
  </UserInfo>
</members>

This is the raw request from SoapUI

POST http://test.app.com/WebServices/MemberService/MemberService.svc HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://test.org/MemberService/GetMemberDetails"
Content-Length: 419
Host: test.app.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

is there a way to get the same kind of raw request from SoapClient in PHP?

edit: I intercepted the request in __doRequest. Here are the differences between SoapClient and SoapUI

SoapClient (receives encoding errors)

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test.org/">
  <SOAP-ENV:Body>
    <ns1:GetMemberDetails>
      <ns1:memberId>123</ns1:memberId>
    </ns1:GetMemberDetails>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

SoapUI (receives correct encoding)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://test.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GetMemberDetails>
         <!--Optional:-->
         <tem:memberId>123</tem:memberId>
      </tem:GetMemberDetails>
   </soapenv:Body>
</soapenv:Envelope>

1 Answer 1

0

make sure php charset is configure correctly

in your php.ini file

default_charset = "UTF-8"
Sign up to request clarification or add additional context in comments.

Comments

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.