繁体   English   中英

PHP SOAP响应编码问题

[英]php SOAP response encoding issue

我要做的就是更改php.ini文件中的默认字符集

default_charset = "UTF-8"

我正在尝试用PHP创建SOAP客户端,但编码时遇到了麻烦。 $ Response的单词带有不正确的字符,如è(而不是è)。

将WSDL文件导入 SoapUI (肥皂测试套件)时,响应会正确编码回来,因此我认为它与SOAP服务无关。 SoapUI表示它正在使用UTF-8。 我也尝试了很多其他 编码 ,但是没有成功。

我所有的php文件均以UTF-8编码。

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

样本响应:

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

这是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)
 
 
  

有没有办法从PHP中的SoapClient获取相同类型的原始请求?

编辑:我在__doRequest中拦截了请求。 这是SoapClient和SoapUI之间的区别

SoapClient(接收编码错误)

 
 
 
 
  
  
  <?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(接收正确的编码)

 
 
 
 
  
  
  <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>
 
 
  

确保php charset配置正确

在您的php.ini文件中

default_charset = "UTF-8"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM