热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何将nuSOAP用于具有多个名称空间的消息-HowtousenuSOAPformessageswithmultiplenamespaces

ImtryingtoaccessaWebServiceusingnuSOAP(becauseImboundtoPHP4here)thatusesmorethan

I'm trying to access a WebService using nuSOAP (because I'm bound to PHP4 here) that uses more than 1 namespace in a message. Is that possible?

我正在尝试使用nuSOAP访问WebService(因为我在这里绑定了PHP4),它在消息中使用了多个命名空间。那可能吗?

An example request message would look like this:

示例请求消息如下所示:


  
  
    
      
        ..
        ..
      
      ..
    
  

I tried to following:

我试着跟随:

$client = new nusoap_client("my.wsdl", true);
$params = array(
  'Person' => array(
    'FirstName'  => 'Thomas',
    ..
   ),
   'Attribute' => 'foo'
 );

 $result = $client->call('myOperation', $params, '', 'soapAction');

in the hope that nuSOAP would try to match these names to the correct namespaces and nodes. Then I tried to use soapval() to generate the elements and their namespace - but if I call an operation, nuSOAP creates the following request:

希望nuSOAP尝试将这些名称与正确的名称空间和节点相匹配。然后我尝试使用soapval()生成元素及其命名空间 - 但是如果我调用一个操作,nuSOAP会创建以下请求:


  
    
  

So something goes wrong during the "matching" phase.

因此在“匹配”阶段出现问题。

4 个解决方案

#1


After trying around with the matching, I found two possible solutions:

在尝试匹配之后,我发现了两种可能的解决方案:

1) Don't use the WSDL to create the nusoap_client and soapval() to create the message This has the disadvantage that the message contains a lot of overhead (the namespace is defined in each element). Not so fine.

1)不要使用WSDL创建nusoap_client和soapval()来创建消息。这样做的缺点是消息包含大量开销(命名空间在每个元素中定义)。不太好。

2) Instead of relying on the matching of parameters, construct your reply in xml and put all the definition for prefixes in the first element - e.g.

2)不是依赖于参数的匹配,而是在xml中构造你的回复并将前缀的所有定义放在第一个元素中 - 例如

$params = "
      
        ..
        ..
      
      ..
    ";

Still not a very nice solution, but it works :-)

仍然不是一个非常好的解决方案,但它的工作原理:-)

#2


Building on Irwin's post, I created the xml manually and had nusoap do the rest. My webhost does not have the php soap extension, so I had to go with nusoap, and the web service I'm trying to consume required the namespaces on each tag (e.g. on username and password in my example here).

在Irwin的帖子的基础上,我手动创建了xml,剩下的就是nusoap。我的webhost没有php soap扩展,因此我不得不使用nusoap,而我正在尝试使用的Web服务需要每个标记上的命名空间(例如,在我的示例中使用用户名和密码)。

require_once('lib/nusoap.php');

$client = new nusoap_client('https://service.somesite.com/ClientService.asmx');
$client->soap_defencoding = 'utf-8';
$client->useHTTPPersistentConnection(); // Uses http 1.1 instead of 1.0
$soapaction = "https://service.somesite.com/GetFoods";

$request_xml = '

  
    
      banjer
      theleftorium
    
  

';

$respOnse= $client->send($request_xml, $soapaction, ''); 

echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
';

Then I had an error that said:

然后我有一个错误说:

Notice: Undefined property: nusoap_client::$operation in ./lib/nusoap.php  on line 7674

So I went the lazy route and went into nusoap.php and added this code before line 7674 to make it happy:

所以我走了懒惰的路线进入nusoap.php并在第7674行之前添加了这段代码以使它开心:

    if(empty($this->operation)) {
        $this->operation = "";
    }

#3


Another bypass this issue would be a modification to nusoap_client::call() function. Next to the this line (7359 in version 1.123) in nusoap.php:

另一个绕过这个问题的是对nusoap_client :: call()函数的修改。在nusoap.php的这一行(版本1.123中的7359)旁边:

$nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace);

$ nsPrefix = $ this-> wsdl-> getPrefixFromNamespace($ namespace);

I added this one:

我添加了这个:

$nsPrefix = $this->wsdl->getPrefixFromNamespace("other_ns_name");

And it worked! Since I only needed this library for one project, it was OK for me to hardcode this hack. Otherwise, I would dig more and modify the function to accept array instead of string for a namespace parameter.

它奏效了!由于我只为一个项目需要这个库,所以我可以硬编码这个hack。否则,我会挖掘更多并修改函数以接受数组而不是字符串作为命名空间参数。

#4


Yeah, i've been having this same problem (found your q via google!) and i've come across this: http://www.heidisoft.com/blog/using-nusoap-consume-net-web-service-10-min Here, the dev creates the xml body of the message in coe and then uses nusoap to submit.

是的,我一直有同样的问题(通过谷歌找到你的q!)我遇到过这个问题:http://www.heidisoft.com/blog/using-nusoap-consume-net-web-service- 10分钟在这里,dev在coe中创建消息的xml主体,然后使用nusoap提交。


推荐阅读
  • 本文介绍了使用AJAX的POST请求实现数据修改功能的方法。通过ajax-post技术,可以实现在输入某个id后,通过ajax技术调用post.jsp修改具有该id记录的姓名的值。文章还提到了AJAX的概念和作用,以及使用async参数和open()方法的注意事项。同时强调了不推荐使用async=false的情况,并解释了JavaScript等待服务器响应的机制。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • 解决nginx启动报错epoll_wait() reported that client prematurely closed connection的方法
    本文介绍了解决nginx启动报错epoll_wait() reported that client prematurely closed connection的方法,包括检查location配置是否正确、pass_proxy是否需要加“/”等。同时,还介绍了修改nginx的error.log日志级别为debug,以便查看详细日志信息。 ... [详细]
  • 网络请求模块选择——axios框架的基本使用和封装
    本文介绍了选择网络请求模块axios的原因,以及axios框架的基本使用和封装方法。包括发送并发请求的演示,全局配置的设置,创建axios实例的方法,拦截器的使用,以及如何封装和请求响应劫持等内容。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • 本文介绍了RPC框架Thrift的安装环境变量配置与第一个实例,讲解了RPC的概念以及如何解决跨语言、c++客户端、web服务端、远程调用等需求。Thrift开发方便上手快,性能和稳定性也不错,适合初学者学习和使用。 ... [详细]
  • 本文介绍了Web学习历程记录中关于Tomcat的基本概念和配置。首先解释了Web静态Web资源和动态Web资源的概念,以及C/S架构和B/S架构的区别。然后介绍了常见的Web服务器,包括Weblogic、WebSphere和Tomcat。接着详细讲解了Tomcat的虚拟主机、web应用和虚拟路径映射的概念和配置过程。最后简要介绍了http协议的作用。本文内容详实,适合初学者了解Tomcat的基础知识。 ... [详细]
  • Webmin远程命令执行漏洞复现及防护方法
    本文介绍了Webmin远程命令执行漏洞CVE-2019-15107的漏洞详情和复现方法,同时提供了防护方法。漏洞存在于Webmin的找回密码页面中,攻击者无需权限即可注入命令并执行任意系统命令。文章还提供了相关参考链接和搭建靶场的步骤。此外,还指出了参考链接中的数据包不准确的问题,并解释了漏洞触发的条件。最后,给出了防护方法以避免受到该漏洞的攻击。 ... [详细]
  • 个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ... [详细]
  • flowable工作流 流程变量_信也科技工作流平台的技术实践
    1背景随着公司业务发展及内部业务流程诉求的增长,目前信息化系统不能够很好满足期望,主要体现如下:目前OA流程引擎无法满足企业特定业务流程需求,且移动端体 ... [详细]
  • 本文介绍了django中视图函数的使用方法,包括如何接收Web请求并返回Web响应,以及如何处理GET请求和POST请求。同时还介绍了urls.py和views.py文件的配置方式。 ... [详细]
  • Imtryingtofigureoutawaytogeneratetorrentfilesfromabucket,usingtheAWSSDKforGo.我正 ... [详细]
  • 本文讨论了如何在codeigniter中识别来自angularjs的请求,并提供了两种方法的代码示例。作者尝试了$this->input->is_ajax_request()和自定义函数is_ajax(),但都没有成功。最后,作者展示了一个ajax请求的示例代码。 ... [详细]
author-avatar
史军2927
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有