php soap 命名空间,PHP中的多个SOAP名称空间(在Python中解决)

我试图用PHP创建这个输出:<?xml version="1.0" encoding="UTF-8"?>

123

PASSword

user@company.com

NG42DJ

这在Python中相当简单,我使用的类(suds)只读取wsdl文件,并正确使用名称空间:

^{pr2}$

不需要引用与名称空间相关的任何内容,它只需读取wsdl文件并进行计算即可。正如您在上面的原始XML中看到的,变量有名称空间,并在需要时继承,还请注意,主体位于ns1名称空间中。在

我在PHP中最接近的是使用WSDL-to-PHP转换器,它基于文件中的函数生成大量的类,但这样做似乎失去了所有名称空间的意义。到目前为止,我看到的唯一方法是修改生成的类文件,如下所示:// some code omitted...

use SoapVar; // added by me

// this is declared in AddressMatchingService namespace

class Credentials

{

public $AgentID = null;

public $Username = null;

public $Password = null;

public function __construct($AgentID, $Username, $Password)

{

//$this->AgentID = $AgentID;

$this->AgentID = new SoapVar($AgentID, null, null, null, null, "http://webservices.company.co.uk/ServiceBase/");

//$this->Username = $Username;

$this->Username = new SoapVar($Username, null, null, null, null, "http://webservices.company.co.uk/ServiceBase/");

//$this->Password = $Password;

$this->Password = new SoapVar($Password, null, null, null, null, "http://webservices.company.co.uk/ServiceBase/");

}

}

$wsdl = base_path() . '/resources/wsdl/AddressMatchingService.wsdl';

$soap = new SoapClient($wsdl, array('trace'=>1));

$creds = new AddressMatchingService\Credentials('123', 'user@company.com','PASSword');

$address = new AddressMatchingService\Address('NG42DJ');

$request = array('request' => $request);

$request = new SoapVar($request, SOAP_ENC_OBJECT);

$response = $soap->__soapCall("GetAvailableAddresses", array('request' => $request));

这让我很接近:<?xml version="1.0" encoding="UTF-8"?>

NG42DJ

123

PASSword

user@company.co.uk

但如果在Python中这么简单,我想我可能做错了什么。在每个类中指定名称空间似乎很痛苦,我仍然不知道是否可以将主体的名称空间从“SOAP-ENV”更改为ns1。如果可以避免的话,我希望避免手工编写XML,因为WSDL中有太多的函数和变量,我希望它能像pythonsuds库那样高效地工作!在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值