我正在从.net到php重写soap web服务.默认情况下,php给我的标签看起来像这样:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Header><ns1:FindAllCategories/></SOAP-ENV:Header><SOAP-ENV:Body><ns1:FindAllCategoriesResponse><ns1:FindAllCategoriesResult><ns1:ArtistCategoryDto>
Run Code Online (Sandbox Code Playgroud)
等等...
但我需要这个:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><FindAllCategoriesResponse xmlns="http://tempuri.org/"><FindAllCategoriesResult><ArtistCategoryDto>
Run Code Online (Sandbox Code Playgroud)
这类似于这里的问题:PHP和SOAP.改变信封, 但我不想像他那样破解它.此外,我正在创建一个将由现有的iphone应用程序使用的soap服务,而不是使用PHP来使用SoapClient来使用soap服务.iPhone应用程序只解析原始xml,我现在无法更改iPhone应用程序.
重新阅读你想要的东西,并在这里搜索php文档是我的解决方案和我做的几个假设
假设
你想要什么?
解
<?php
// Create you parse function - Regex
function SoapServerRegexParser($input)
{
// $input contains your XML Response
// Do str_replace or preg_replace
$request = preg_replace({do replace});
//return modified output to client
return $request;
}
// OR create you parse function - Regex XML Parser
function SoapServerXMLParser($input)
{
// $input contains your XML Response
// Use any xml parser that you would like
$xml = new DOMDocument();
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;
$xml->loadXML($input);
//Do replacement have a looke at: DOMNode::replaceChild
//return modified output to client
return $xml->saveXML();
}
// Make php buffer all output
// Send all output to a callBack function
// Replace 'SoapServerRegexParser' with the callback function name of choice
ob_start('SoapServerRegexParser'); //buffer output and set callback function
// Create SoapServer
$server = new SoapServer('wsdlfile.wsdl');
$server->handle(); //Handle incoming request
ob_end_flush(); //Release buffer, but send through callback function first
?>
Run Code Online (Sandbox Code Playgroud)
这应该是技巧,我没有创建正则表达式部分或实际的xlm节点替换,但我想你可以自己做
| 归档时间: |
|
| 查看次数: |
12808 次 |
| 最近记录: |