簡體   English   中英

在nusoap中傳遞xml

[英]passing an xml in nusoap

美好的一天,

我無法在nusoap中傳遞xml。

示例:我通過此xml

<test>123</test>

nusoap響應是

test123/test

大於和小於符號將被刪除。

這是我的服務器代碼:


require_once('nusoap/nusoap.php');
$server = new nusoap_server; // Create server instance

$server->configureWSDL('demows','http://example.org/demo');

$server->register('myFunction',
    array("param"=>"xsd:string"), // input
    array("result"=>"xsd:string"), // output
    'http://example.org/demo'
);

function myFunction($parameters) {
    return $parameters;
}

// Use the request to try to invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA: '';
$server->service($HTTP_RAW_POST_DATA);

這是我給客戶的代碼:


require_once('nusoap/nusoap.php');

$client = new nusoap_client('http://localhost/nusoap/ws.php?wsdl', true);

$clientparam = '<test>123</test>';

$result = $client->call('myFunction', 
    array('param'=>$clientparam)
);

print_r($result);

*請注意,以上代碼在PHP版本5.3.0上有效,但在PHP版本5.2.0-8 + etch13上無效,這是我們生產中使用的代碼。

我已經在網上搜索了2版的所有問題,但均未找到。 非常感謝您的幫助。 TIA

升級libxml2並重建PHP。

如果要在肥皂消息中傳遞xml值,並且同時控制服務器和客戶端(或者至少可以指示客戶端),那么為什么不對base64進行xml編碼。 然后解析器將其視為普通字符串,不會感到困惑。

我一點都不了解nusoap,但聽起來您的實體正在被丟棄。 可能有必要在任一端控制實體,例如通過將&gt;更改為'>',將&lt;更改為'<'。 手動或使用htmlentities()之類的函數

不知道您使用的不是我的其他版本的nusoap,但是我一直在使用代理,這似乎可以正常工作。 我還使用soapclient而不是nusoap_client實例化了客戶端(之前沒有見過):

 $client = new soapclient('http://localhost/nusoap/ws.php?wsdl', true);
 $proxy = $client->getProxy();
 $response = $proxy->call("myfunction", array('test' => 123));

是的,答案是在soapval類中。

有些凌亂,但簡單的例子是在這里 快速-您必須用此類包裝任何非泛型類型,即php數組。 這種包裝的嵌套當然可以發生,但這並不違背設計。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM