PHP SoapClient 无法处理消息,因为内容类型为 'text/xml; [英] PHP SoapClient Cannot process the message because the content type 'text/xml;

查看:18
本文介绍了PHP SoapClient 无法处理消息,因为内容类型为 'text/xml;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法连接到网络服务和发送/接收数据

错误

<块引用>

HTTP,无法处理消息,因为内容类型为'text/xml;charset=utf-8' 不是预期的类型 'application/soap+xml;字符集=utf-8'.

代码

<前>$参数 = ['用户名' => 12324,'密码' => 432123,'Bill_Id' => 153585611140,'Payment_Id' => 8560103,];$url="https://bill.samanepay.com/CheckBill/BillStateService.svc?wsdl";$method = "VerifyBillPaymentWithAddData";$client = new SoapClient($url);尝试{$info = $client->__call($method, array($parameters));}catch (SoapFault $fault){die($fault->faultcode.','.$fault->faultstring);}

Notice :在 stackoverflow 中此错误的 Soap 版本 1,1 和其他解决示例不起作用.

解决方案

你可以试试

$url = "https://bill.samanepay.com/CheckBill/BillStateService.svc?wsdl";尝试 {$client = new SoapClient($url, [soap_version" =>SOAP_1_2,//SOAP_1_1'cache_wsdl' =>WSDL_CACHE_NONE,//WSDL_CACHE_MEMORY'跟踪' =>1、'例外' =>1、'keep_alive' =>错误的,'connection_timeout' =>500000]);print_r($client->__getFunctions());} 抓住(SOAPFault $f){error_log('ERROR => '.$f);}

验证您的方法名称是否正确.

在那里你可以看到方法

VerifyBillPaymentWithAddDataResponse VerifyBillPaymentWithAddData(VerifyBillPaymentWithAddData $parameters)

接下来是检查类型 VerifyBillPaymentWithAddData 以及参数是否可以是数组.您也可以测试通过

调用该方法

$client->VerifyBillPaymentWithAddData(['用户名' =>12324,'密码' =>432123,'Bill_Id' =>153585611140,'Payment_Id' =>8560103,]);

或者你的,除了额外的数组

$info = $client->__call($method, $parameters);

假设 https://stackoverflow.com/a/5409465/1152471 错误可能在服务器端,因为服务器发回与 SOAP 1.2 标准不兼容的标头.

也许您必须使用第三方库甚至简单的套接字才能使其正常工作.

I cannot connect to webservice and send/receive data

Error

HTTP,Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.

Code


    $parameters = [
        'UserName' => 12324,
        'Password' => 432123,
        'Bill_Id' => 153585611140,
        'Payment_Id' => 8560103,
    ];

    $url="https://bill.samanepay.com/CheckBill/BillStateService.svc?wsdl";
    $method = "VerifyBillPaymentWithAddData";

    $client = new SoapClient($url);

    try{

        $info = $client->__call($method, array($parameters));

    }catch (SoapFault $fault){  

        die($fault->faultcode.','.$fault->faultstring);

    }

Notice : not work Soap version 1,1 and other resolve sample for this error in stackoverflow.

解决方案

You could try

$url = "https://bill.samanepay.com/CheckBill/BillStateService.svc?wsdl";

try {
    $client = new SoapClient($url, [
        "soap_version" => SOAP_1_2, // SOAP_1_1
        'cache_wsdl' => WSDL_CACHE_NONE, // WSDL_CACHE_MEMORY
        'trace' => 1,
        'exception' => 1,
        'keep_alive' => false,
        'connection_timeout' => 500000
    ]);
    print_r($client->__getFunctions());
} catch (SOAPFault $f) {
    error_log('ERROR => '.$f);
}

to verify that your method name is correct.

There you can see the method

VerifyBillPaymentWithAddDataResponse VerifyBillPaymentWithAddData(VerifyBillPaymentWithAddData $parameters)

Next is to check the Type VerifyBillPaymentWithAddData and if the parameter can be an array. Also you could test to call the method via

$client->VerifyBillPaymentWithAddData([
    'UserName' => 12324,
    'Password' => 432123,
    'Bill_Id' => 153585611140,
    'Payment_Id' => 8560103,
]);

or yours except the additional array

$info = $client->__call($method, $parameters);

EDIT: Assuming to https://stackoverflow.com/a/5409465/1152471 the error could be on the server side, because the server sends an header back that is not compatible with SOAP 1.2 standard.

Maybe you have to use an third party library or even simple sockets to get it working.

这篇关于PHP SoapClient 无法处理消息,因为内容类型为 'text/xml;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆