沃梦达 / 编程问答 / php问题 / 正文

调试 PHP SOAP 调用

Debugging PHP SOAP call(调试 PHP SOAP 调用)

本文介绍了调试 PHP SOAP 调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 SOAP 新手,正在处理一项 Web 服务,以前似乎没有人使用 PHP 进行连接.除了 C#,他们没有示例代码,但我有.eServices.asmx 提供了 WSDL,如果这是正确的说法的话.

I am new to SOAP and dealing with a web service where it would seem no one has interfaced using PHP previously. They have no example code excepting C# but I do have that. eServices.asmx provides WSDL if that is the correct way to say that.

我得到的错误是服务器无法识别 HTTP Header SOAPAction 的值:",其中训练冒号表明可能没有传递任何值.

The error that I am getting is "Server did not recognize the value of HTTP Header SOAPAction:" with that training colon suggesting no value is passed, maybe.

我的代码如下:

$URL = "http://nolaflash.example.com/xxxWS/eServices.asmx";

$namespace="http://www.example.com/webservices/";

include("SOAP/Client.php");

$soapclient = new SOAP_Client($URL);

$xml_data = // valid XML is here;

$res = $soapclient->UpdateData('usrname','pass',$xml_data);

但我也尝试过:

$param = array('usrname','pass',$xml_data);
$res = $soapclient->call('UpdateData',$param, $namespace);

谷歌搜索表明此错误是命名空间问题.我的 C# 代码只有一个命名空间引用:

Googling suggests that this error is a namespace issue. The C# code I have has only one namespace reference:

[System.Web.Services.WebServiceBindingAttribute(Name="eServicesSoap", Namespace="http://www.example.com/webservices/")]

如果我在函数调用之前将 $soapclient 转储到屏幕上,我会看到它已从 eServices.asmx 接收到数据.

If I dump $soapclient to the screen prior to the function call I see that it has received data from eServices.asmx.

我不确定如何进行调试,而且该服务的工作人员不熟悉在其 .NET IDE 之外与该服务进行交互.

I am unsure how to go about debugging this and the staffers at the service are unfamiliar with interacting with the service outside their .NET IDE.

有什么想法吗?建议?

推荐答案

我通常使用的方法是 getFunctions和 getLastRequest帮我解决问题.首先我看一下函数列表和WSDL.有时 WSDL 和/或服务器未正确设置/配置/编码.所以这个函数列表可能没用.WSDL 文件应该是明确的,但是唉,编码器很烂,等等...

I usually use the methods getFunctions and getLastRequest to help me sort things out. First I look at the function list and WSDL. Sometimes the WSDL and/or server is not setup/configured/coded properly. So this function list may be useless. The WSDL file should be definitive, but alas, lame coders, etc...

所以有时我不得不暗中探查,查看错误,然后查看最后一个请求.这样您就可以看到生成的实际 XML.将其与一些有效的 XML 示例进行比较.

So sometimes I have to take a stab in the dark, look at the error, and then look at the last request. With this you can see the actual XML that was produced. Compare that to some working XML examples.

事实证明,这在与不想编写文档的编码人员打交道时最有帮助.顺便说一下,他们应该给出 XML 示例——而不是展示如何使用 XYZ 语言生成 XML.PHP/Soap 文档

This has proven most helpful when dealing with coders who don't want to write docs. By the way, they should give XML examples - not show how to generate XML using language XYZ. There may be more useful infos in the PHP/Soap documentation

HTH

这篇关于调试 PHP SOAP 调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:调试 PHP SOAP 调用

基础教程推荐