gpt4 book ai didi

java - SoapFault 异常 : [HTTP] Unsupported Media Type when accessing Java web-service from PHP

转载 作者:可可西里 更新时间:2023-11-01 12:40:12 25 4
gpt4 key购买 nike

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

<?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>';
?>

输出:

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

知道哪里出了问题吗? url 是正确的,因为我在调用时获得了可用的函数

$client->getFunctions()

最佳答案

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

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.

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

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

关于java - SoapFault 异常 : [HTTP] Unsupported Media Type when accessing Java web-service from PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1617857/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com