SoapFault 异常:[HTTP] 从 PHP 访问 Java Web 服务时不受支持的媒体类型 [英] SoapFault exception: [HTTP] Unsupported Media Type when accessing Java web-service from PHP

查看:20
本文介绍了SoapFault 异常:[HTTP] 从 PHP 访问 Java Web 服务时不受支持的媒体类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Zend Framework v1.9.0 中的 Zend_Soap_Client 连接到 Java Web 服务:

'UTF-8'));尝试{$result = $client->find_customer(array('username' =>'user','密码' =>'123'), array('city' => 'some city'));} catch(异常$e){回声 $e;}echo '

'.$client->getLastRequestHeaders() .'</pre>';?>

输出:

SoapFault 异常:[HTTP] 不支持的媒体类型/Library/ZendFramework-1.9.0/library/Zend/Soap/Client.php:937堆栈跟踪:#0 [内部功能]:SoapClient->__doRequest('_doRequest(Object(Zend_Soap_Client_Common),'__doRequest('__soapCall('find_customer', Array, NULL, NULL, Array)#6【内部功能】:Zend_Soap_Client->__call('find_customer', Array)#7/Users/webservicetest/index.php(8):Zend_Soap_Client->find_customer(Array, Array)#8 {主要}POST/webservice-war/webservice HTTP/1.1主机:webservice.com连接:保持活动用户代理:PHP-SOAP/5.2.6内容类型:应用程序/soap+xml;字符集=utf-8;行动=""内容长度:315

知道哪里出了问题吗?网址是正确的,因为我在调用时获得了可用的功能

$client->getFunctions()

解决方案

根据 this列表,异常表明托管网络服务的服务器对您的请求编码不满意:

<块引用>

表示对端HTTP服务器不支持使用的内容类型对请求消息进行编码.这消息交换被认为具有未成功完成.

因此,您应该与网络服务提供商确认他们期望的内容类型/编码.

如果您使用 SOAP_1_2,一个可能的解决方案是更改为 SOAP_1_1,因为这会改变发出的请求.

I'm trying to connect to a Java web-service using the Zend_Soap_Client from the Zend Framework v1.9.0:

<?php
include( 'Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance();
$client = new Zend_Soap_Client('https://webservice.com/webservice-war/webservice?wsdl'
    , array('encoding'=> 'UTF-8'));

try{
    $result = $client->find_customer(array('username' => 'user', 
                         'password' => '123'), array('city' => 'some city'));
} catch(Exception $e){
    echo $e;
}

echo '<pre>' . $client->getLastRequestHeaders() . '</pre>'; 
?>

Outputs:

SoapFault exception: [HTTP] Unsupported Media Type in 
/Library/ZendFramework-1.9.0/library/Zend/Soap/Client.php:937 
Stack trace: 
 #0 [internal function]:
SoapClient->__doRequest('_doRequest(Object(Zend_Soap_Client_Common),
    '__doRequest('__soapCall('find_customer', Array, NULL, NULL, Array) 
 #6 [internal function]:  
 Zend_Soap_Client->__call('find_customer', Array) 
 #7 /Users/webservicetest/index.php(8): 
 Zend_Soap_Client->find_customer(Array, Array) 
 #8 {main}

POST /webservice-war/webservice HTTP/1.1
Host: webservice.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.2.6
Content-Type: application/soap+xml; charset=utf-8; action=""
Content-Length: 315

Any idea what could be wrong? The url is correct, since I get the availible functions when calling

$client->getFunctions()

解决方案

According to this listing, the exception indicates that the server hosting the web-service is not happy with your requests encoding:

Indicates that the peer HTTP server does not support the Content-type used to encode the request message. The message exchange is regarded as having completed unsuccessfully.

So you should check with the web-service provider concerning the content-type/encoding they expect.

A possible solution if you are using SOAP_1_2is to change to SOAP_1_1 since that will alter the requests made.

这篇关于SoapFault 异常:[HTTP] 从 PHP 访问 Java Web 服务时不受支持的媒体类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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