gpt4 book ai didi

zend-framework - Zend Soap Client 标签名称

转载 作者:行者123 更新时间:2023-12-04 04:50:19 24 4
gpt4 key购买 nike

我正在尝试将 .net WSDL 服务与 Zend Soap Client 连接。我使用下面的代码;

$client = new Zend_Soap_Client("http://ws.test.com/test/services/service.asmx", array(

'uri' => 'http://tempuri.org',
'soap_version' => SOAP_1_1,
'wsdl' => 'http://ws.test.com/test/services/service.asmx?wsdl'
));

$client->DoInventoryItemImport(array(
'DepositorID_' => '123',
'UserName_' => 'ABC',
'Password_' => '123123',
'SecurityKey_' => '',
'ContinueOnError_' => true,
'Items_' => array(
'InventoryItem' => array(
'Code' => 'testcode',
'Description' => 'test description',
'Abccode' => 'test',
'Weight' => 10.10,
'ItemMainCategory' => 'testCategory',
'Depositor' => 'ABC',
'DepositorCode' => '123'
)
)

));

此代码发送一个与此完全相同的 SOAP 信封;
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:DoInventoryItemImport>
<ns1:Items_>
<ns1:InventoryItem>
<ns1:Code>testcode</ns1:Code>
<ns1:Description>test description</ns1:Description>
<ns1:Abccode>test</ns1:Abccode>
<ns1:AllocatesAgainstQCPolicy xsi:nil="true"/>
<ns1:SafetyStockCU xsi:nil="true"/>
<ns1:TemplateItem xsi:nil="true"/>
<ns1:MinimumOrderQTY xsi:nil="true"/>
<ns1:IsLoadBatch xsi:nil="true"/>
<ns1:Weight>10.1</ns1:Weight>
<ns1:Volume xsi:nil="true"/>
<ns1:Diameter xsi:nil="true"/>
<ns1:IsTemporaryItem xsi:nil="true"/>
<ns1:IsKitItem xsi:nil="true"/>
<ns1:ItemMainCategory>testCategory</ns1:ItemMainCategory>
<ns1:IsFragile xsi:nil="true"/>
<ns1:IsPackingItem xsi:nil="true"/>
<ns1:Depositor>ABC</ns1:Depositor>
<ns1:DepositorCode>123</ns1:DepositorCode>
</ns1:InventoryItem>
</ns1:Items_>
<ns1:UserName_>ABC</ns1:UserName_>
<ns1:Password_>123123</ns1:Password_>
<ns1:SecurityKey_></ns1:SecurityKey_>
<ns1:ContinueOnError_>true</ns1:ContinueOnError_>
</ns1:DoInventoryItemImport>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

但正如我从他们的服务定义中了解到的,他们想要一个像这样的 SOAP 信封;
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<DoInventoryItemImport xmlns="http://tempuri.org/">
<Items_>
<InventoryItem>
<Code>testcode</Code>
<Description>test description</Description>
<Abccode>test</Abccode>
<AllocatesAgainstQCPolicy>true</AllocatesAgainstQCPolicy>
<SafetyStockCU>1</SafetyStockCU>
<TemplateItem>true</TemplateItem>
<MinimumOrderQTY>1</MinimumOrderQTY>
<IsLoadBatch>true</IsLoadBatch>
<Weight>10.1</Weight>
<Volume>1</Volume>
<Diameter>1</Diameter>
<IsTemporaryItem>true</IsTemporaryItem>
<IsKitItem>true</IsKitItem>
<ItemMainCategory>testCategory</ItemMainCategory>
<IsFragile>true</IsFragile>
<IsPackingItem>true</IsPackingItem>
<Depositor>ABC</Depositor>
<DepositorCode>123</DepositorCode>
</InventoryItem>
</Items_>
<UserName_>ABC</UserName_>
<Password_>123123</Password_>
<SecurityKey_></SecurityKey_>
<ContinueOnError_>true</ContinueOnError_>
</DoInventoryItemImport>
</soap:Body>
</soap:Envelope>

实际上这些信封包含相同的数据并且它们的结构匹配。但我不知道如何将 SOAP-ENV 之类的标签名称更改为 soap 并删除诸如“ns1:”之类的前缀。

我认为我的 Zend Soap 客户端配置有误?

最佳答案

我通过重载 Zend Soap Client 解决了这个问题。我使用 str_ireplace 函数将 'ns1:' 替换为 '' on request 变量。然后我使用我的自定义客户端进行连接。希望这对某人有帮助。

class My_Client extends Zend_Soap_Client_DotNet{

public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null)
{
if ($one_way == null) {
return call_user_func(array($client,'SoapClient::__doRequest'), str_ireplace('ns1:', '', $request), $location, $action, $version);
} else {
return call_user_func(array($client,'SoapClient::__doRequest'), str_ireplace('ns1:', '', $request), $location, $action, $version, $one_way);
}
}

}

关于zend-framework - Zend Soap Client 标签名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17521942/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com