如何删除 Zend_Soap 中的名称空间?
我正在尝试使用 MyMemory 中的翻译 Web 服务: http://mymemory.translated.net/doc /spec.php
不幸的是,Zend_Soap_Client 确实生成了服务无法识别的 XML reqest 对象。我想这是因为标签内的 ns1 属性(命名空间)。那么有谁知道如何删除它们吗?
这基本上就是我所做的:
$client = new Zend_Soap_Client('http://mymemory.translated.net/otms/?wsdl', array(
'soap_version' => SOAP_1_1
));
然后我调用该函数:
try {
$client->otmsGet(array(
'key' => 'xxx',
'q' => array(
'source' => 'Computer Science',
'source_lang' => 'en-US',
'target_lang' => 'de-DE'
)
));
} catch(Exception $e) {
print $client->getLastRequest();
}
生成的 XML 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:otmsGet>
<ns1:key>xxx</ns1:key>
<ns1:q>
<ns1:source>Computer Science</ns1:source>
<ns1:source_lang>en-US</ns1:source_lang>
<ns1:target_lang>de-DE</ns1:target_lang>
</ns1:q>
</ns1:otmsGet>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
它实际上应该看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<otmsGet xmlns="http://tempuri.org/">
<key xmlns:SOAPSDK1="http://tempuri.org/">mmDemo123</key>
<q xmlns:SOAPSDK2="http://tempuri.org/">
<source>control panel</source>
<source_lang>en-US</source_lang>
<target_lang>es-ES</target_lang>
</q>
</otmsGet>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
感谢您的帮助!
I am trying to use the tranlsation webservice from MyMemory: http://mymemory.translated.net/doc/spec.php
Unfortunately, Zend_Soap_Client does generate an XML reqest object that is not recognized by the service. I guess it is because of the ns1-Attribute (Namespace) within the tags. So does anyone know how to remove them?
That's basically what I do:
$client = new Zend_Soap_Client('http://mymemory.translated.net/otms/?wsdl', array(
'soap_version' => SOAP_1_1
));
Then I call the function:
try {
$client->otmsGet(array(
'key' => 'xxx',
'q' => array(
'source' => 'Computer Science',
'source_lang' => 'en-US',
'target_lang' => 'de-DE'
)
));
} catch(Exception $e) {
print $client->getLastRequest();
}
The resulting XML looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:otmsGet>
<ns1:key>xxx</ns1:key>
<ns1:q>
<ns1:source>Computer Science</ns1:source>
<ns1:source_lang>en-US</ns1:source_lang>
<ns1:target_lang>de-DE</ns1:target_lang>
</ns1:q>
</ns1:otmsGet>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And it should actually look like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<otmsGet xmlns="http://tempuri.org/">
<key xmlns:SOAPSDK1="http://tempuri.org/">mmDemo123</key>
<q xmlns:SOAPSDK2="http://tempuri.org/">
<source>control panel</source>
<source_lang>en-US</source_lang>
<target_lang>es-ES</target_lang>
</q>
</otmsGet>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我必须创建一个包装器:
I had to create a wrapper:
对于 Zend 2 应用程序,您可以向控制器添加一个额外的类,以动态替换肥皂请求。
例子:
For a Zend 2 app you can add an extra class to your controller that substitutes on the fly the soap request.
Example: