在SOAP中包含html

时间:2014-08-01 13:59:37

标签: php html soap wsdl nusoap

我正在使用NuSOAP服务器/客户端在我自定义的CMS中创建帖子。 我尝试发送两件事:帖子标题(字符串)和帖子的HTML代码。问题是HTML没有被正确接收:大部分时间只是(随机)部分。

我的代码:

NuSOAP服务器

$page_wsdl  = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'] . '?wsdl';
$server     = new soap_server();
$server->configureWSDL("SOAP server", $page_wsdl);

$server->register("createPost",
    array("post_title" => "xsd:string", "post_html" => "xsd:string"),
    array("return" => "xsd:string"),
    "$page",
    "$page#createPost",
    "rpc",
    "encoded",
    "Create posts");

NuSOAP客户端

$client = new nusoap_client("http://server/soap.php?wsdl=1");
$client->soap_defencoding = 'UTF-8';   

$result = $client->call("createPost", array("post_title" => $title, "post_html" => $html));
print_r($result);

    if ($client->fault) {
            echo $error;
    }

使用SOAP发送HTML的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

客户端的htmlentities()和服务器端的html_entity_decode()似乎是解决方案。