如何在php中使用nusoap为每个函数生成xml描述?

时间:2015-04-26 08:42:29

标签: php xml web-services soap nusoap

我在php中使用nusoap开发了一个soap api。我为此创建了一些功能。我创建了一个文件 service.php &当我在url上点击这个文件时,我得到了一个所有功能的文件。像这样:

  

enter image description here   My nusoap DOC

但我想为我的函数提供类似xml的描述。像这样:

  

enter image description here   REQUIRED OUTPUT

请告诉我该怎么做

这是 service.php

的代码
<?php
require_once "lib/nusoap.php";
require_once "functions.php";
$server=new nusoap_server();
$server->configureWSDL("SOAP", "urn:soapn");
$server->register("addRecord",
        array("fname"=>"xsd:string","lname"=>"xsd:string","buis_name"=>"xsd:string","phone_num"=>"xsd:int","city"=>"xsd:string","state"=>"xsd:string",           "zipcode"=>"xsd:int","email"=>"xsd:string"
        ,"w_store"=>"xsd:string","con_store"=>"xsd:string","ind_store"=>"xsd:string","gas_staion"=>"xsd:string","other"=>"xsd:string"),
        array("return" => "xsd:string"),
        "urn:soap",
       "urn:soap#addRecord",
       "rpc",
       "encoded",
      "Add user information to database");
 $server->register("checkLogin",
        array("email"=>"xsd:string","password"=>"xsd:string"),
        array("return" => "xsd:string"),
        "urn:soap",
       "urn:soapn#checkLogin",
       "rpc",
       "encoded",
      "Verify UserLogin"); 
$HTTP_RAW_POST_DATA=isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

1 个答案:

答案 0 :(得分:0)

屏幕截图中的XML是一个示例SOAP请求和SOAP响应。

要生成它,您需要创建这样的示例请求并获取它的原始XML。请求的XML以及响应。

您应该可以通过向本地服务器创建请求来自动执行此操作。

以下相关Q&amp; A:

中解释了获取原始XML