致命错误:未捕获的 SoapFault 异常:[WSDL] [英] Fatal error: Uncaught SoapFault exception: [WSDL]

查看:46
本文介绍了致命错误:未捕获的 SoapFault 异常:[WSDL]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调用从 PHP 设置的 Web 服务时遇到问题.以下错误消息中的混淆地址 http://XXX.XXX.XXX.XXX/test.asmx?wsdl 返回有效的 WSDL.我已成功尝试使用 VB.net 客户端将其称为 Web 服务,但是当我在 Debian 上从 PHP 调用它时,我收到以下消息:

<前>致命错误:未捕获的 SoapFault 异常:[WSDL] SOAP-ERROR:解析 WSDL:无法从http://XXX.XXX.XXX.XXX/test.asmx?wsdl"加载在/var/www/domain/mywebsite.com/public_html/catalog/fomeus/orders.php:101堆栈跟踪:#0/var/www/domain/mywebsite.com/public_html/catalog/fomeus/orders.php(101):SoapClient->SoapClient('http://XXX.XXX.XXX.XXX/', Array) #1 {main} 抛出在/var/www/domain/mywebsite.com/public_html/catalog/fomeus/orders.php在第 101 行

可能是什么问题?我在下面包含了我的网络服务和 PHP 客户端代码.

网络服务:

导入 System.Web.Services导入 System.Web.Services.Protocols导入 System.ComponentModel...' 要允许使用 ASP.NET AJAX 从脚本调用此 Web 服务,请取消注释以下行.' <System.Web.Script.Services.ScriptService()>_<System.Web.Services.WebService(Namespace:="http://tempuri.org/")>_<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>_<ToolboxItem(False)>_公共类 WebService1继承 System.Web.Services.WebService<WebMethod()>_公共函数 HelloWorld() 作为字符串返回你好世界"结束函数结束类

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());

如果有帮助的话,我使用的是 PHP 5.2.6 版.我已经在不同的论坛上浏览了大量帖子,试图找出问题所在.很多人都遇到过同样的问题,但到目前为止我找到的解决方案都没有对我有用.任何帮助将不胜感激.

解决方案

另一个可以查看的选项是 cURL.您可以将负载创建为 XML 字符串,并使用 cURL 将其发送到相同的 URL.然后,您需要根据需要捕获响应代码并进行处理.当我在使用 SOAPClient 时遇到问题时,我转向了 cURL - 非常有用.

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:

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 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:

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.

解决方案

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.

这篇关于致命错误:未捕获的 SoapFault 异常:[WSDL]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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