php 致命错误:未捕获的 SoapFault 异常:[WSDL]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4906871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fatal error: Uncaught SoapFault exception: [WSDL]
提问by Daniel
I'm having trouble calling a web service I've set up from PHP. The obfuscated adress http://XXX.XXX.XXX.XXX/test.asmx?wsdl
in the error message below returns a valid WSDL. I've successfully tried to call it as a web service using a VB.net client, but when I call it from PHP on Debian I get the following message:
我在调用从 PHP 设置的 Web 服务时遇到问题。http://XXX.XXX.XXX.XXX/test.asmx?wsdl
以下错误消息中的混淆地址返回有效的 WSDL。我已经成功地尝试使用 VB.net 客户端将它称为 Web 服务,但是当我在 Debian 上从 PHP 调用它时,我收到以下消息:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://XXX.XXX.XXX.XXX/test.asmx?wsdl' in /var/www/domain/mywebsite.com/public_html/catalog/fomeus/orders.php:101 Stack trace: #0 /var/www/domain/mywebsite.com/public_html/catalog/fomeus/orders.php(101): SoapClient->SoapClient('http://XXX.XXX.XXX.XXX/', Array) #1 {main} thrown in /var/www/domain/mywebsite.com/public_html/catalog/fomeus/orders.php on line 101
What could the problem be? I've included my code for the web service and the PHP client below.
可能是什么问题?我在下面包含了我的 Web 服务和 PHP 客户端代码。
Web Service:
网络服务:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
...
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class WebService1
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
PHP client:
PHP客户端:
require_once($_SERVER['DOCUMENT_ROOT']."/catalog/fomeus/includes/soap/nusoap.php");
$objClient = new soapclient("http://XXX.XXX.XXX.XXX/test.asmx?wsdl",
array('trace' => 1, 'exception' => 0, 'cache_wsdl' => 0));
print_r($objClient -> HelloWorld());
I'm using PHP version 5.2.6 if that's of any help. I've been going through plenty of posts in different forums trying to figure out what the problem is. Many people have had the same issue, but none of the solutions I've found so far work for me. Any help would be greatly appreciated.
如果有任何帮助,我正在使用 PHP 5.2.6 版。我已经在不同的论坛上浏览了大量帖子,试图找出问题所在。很多人都遇到过同样的问题,但到目前为止我找到的解决方案都没有对我有用。任何帮助将不胜感激。
回答by Tash Pemhiwa
Another option to look at is cURL. You can create your payload as an XML string and send it to the same URL using cURL. You would then need to capture the response code and process as appropriate. When I had issues with SOAPClient, I moved to cURL - works like a charm.
另一个要查看的选项是 cURL。您可以将负载创建为 XML 字符串,并使用 cURL 将其发送到相同的 URL。然后,您需要根据需要捕获响应代码并进行处理。当我遇到 SOAPClient 问题时,我转向了 cURL - 就像一个魅力。
回答by surferdude
try to turn on php_soap.dll and php_openssl.dll in your php.ini. Located in the apache folder \apache\apache2.4.2\bin
尝试打开 php.ini 中的 php_soap.dll 和 php_openssl.dll。位于 apache 文件夹 \apache\apache2.4.2\bin
remove the ";"
去除那个 ”;”
回答by Mukesh
Adding index.php worked for me working on php application
添加 index.php 对我在 php 应用程序上工作
$client = new SoapClient('http://www.domain.com/api/v2_soap/?wsdl'=1)
$client = new SoapClient('http://www.domain.com/index.php/api/v2_soap/?wsdl'=1)
回答by Warren Krewenki
If you're using nusoap (php 5.2 has a native soapclient, which I prefer), the first thing I see is your arguments. Argument #2 for nusoap's soapclient constructor should be boolean TRUE here, if you're using the WSDL, and not an array. Try:
如果您使用的是 nusoap(php 5.2 有一个本地的soapclient,我更喜欢),我看到的第一件事就是您的论点。如果您使用的是 WSDL,而不是数组,那么 nusoap 的 soapclient 构造函数的参数 #2 在这里应该是布尔值 TRUE。尝试:
$objClient = new soapclient("http://XXX.XXX.XXX.XXX/test.asmx?wsdl",true);
print_r($objClient->HellowWorld());
That's how i've been able to work with wsdl in the past.
这就是我过去能够使用 wsdl 的方式。
If you're using the native client, and having problems with the wsdl, you can always bypass it and make straight calls, like so:
如果您使用本机客户端,并且 wsdl 有问题,您可以随时绕过它并直接调用,如下所示:
$objClient = new soapclient(null,array('uri'=>'http://xxx/test.asmx','location'=>'http://xxx/test.asm'));
$objClient->__call('HelloWorld',array());
That should work, but isn't as easy to navigate as wsdl.
这应该可行,但不像 wsdl 那样容易导航。