带有PHP Soap的Umlauts请求

时间:2019-03-06 15:08:38

标签: php soap

所以我有类似这样的SOAP请求:

const
    swap = (a, i = 0) => () => {
        a.splice(i, 0, ...a.splice(++i, 1));
        return a;
    };

var array = ["author", "1", "2", "3", "5", "6"],
    s = swap(array);

console.log(...array);
console.log(...s());
console.log(...s());
console.log(...s());
console.log(...s());
console.log(...s());
console.log(...s());

现在结果在德语中带有变音符号(ä,ö,)等等。但是例如,当我打印结果时ä出现¤。这是为什么?与simplexml_load_string或我的Soap请求有关吗?

2 个答案:

答案 0 :(得分:0)

我认为您回复的内容标头不是UTF-8。

尝试

header('Content-Type:text / html; charset = utf-8');

在打印输出之前。

答案 1 :(得分:0)

对您的Soap请求使用php SoapClient,像这样构造您的请求

        $options = array('trace'=> true,'exceptions' => true);            
        $client  = new \SoapClient('https://www.example.com?wsdl',$options);

        $params = new \stdClass();
        $params->yourKeyorIdHere = 'XXXXXX';
        $params->YourKeyOrIDHere = 'XXXXX';
        $soapVar = new \SoapVar($params,SOAP_ENC_OBJECT);

        $header = new \SoapHeader('https://www.example?wsdl','credentials',$soapVar);

        $client->__setSoapHeaders(array($header));


        $result=$client->login(function parameters here);