dsgk40568 2010-07-20 01:40
浏览 48
已采纳

Nusoap - 修复响应的空xmlns属性

i have created a simple web service using Php Nusoap. its working correctly but the only thing missing is to add the default xmlns attribute to the response tag.

Here is the copy of Response :

    <?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <LoginResponse xmlns="">
      <LoginResult>
        <register>
          <customer>d2ff3b88d34705e01d150c21fa7bde07</customer>
        </register>
      </LoginResult>
    </LoginResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Here is the code :

<?php

require_once ('nusoap.php');
// set namespace
$ns = 'mynamspace';
// set up soap server
$server = new soap_server ();
$server->configureWSDL ( 'testservice', $ns);
$server->wsdl->schemaTargetNamespace = $ns;
// define new user data type


// define results


$server->wsdl->addComplexType ( 'customer', 'complexType', 'struct', '', '', array ('customer' => array ('name' => 'customer', 'type' => 'xsd:string' ) ) );
$server->wsdl->addComplexType ( 'register', 'complexType', 'struct', '', '', array ('register' => array ('name' => 'register', 'type' => 'tns:customer' ) ) );
$server->wsdl->addComplexType ( 'LoginResult', 'complexType', 'struct', '', '', array ('LoginResult' => array ('name' => 'LoginResult', 'type' => 'tns:register' ) ) );

// register Login function
$server->register ( 'Login', // method name
array ('username' => 'xsd:string', 'password' => 'xsd:string' ), // input parameters
array ('LoginResult' => 'tns:register' ), // output parameters
'urn:mynamespace', // namespace
'urn:mynamespaceAction', // soapaction
'document', // style
'literal', // use
'Login service for testing' ); // documentation


function Login($username, $password) {
    if (isset ( $username ) && isset ( $password )) {
        $hash = md5 ( $username );
        return array ('LoginResult' => array ('register' => array ('customer' => $hash ) ));

    } 
}

// 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 );
?>

Any help is greatly appreciated.

  • 写回答

1条回答 默认 最新

  • dongmang3961 2010-08-24 21:14
    关注

    I don't claim this is particularly elegant, but worked in my case:

    I went into the nusoap.php and commented this line (line 5925 for me):

    //$elementNS = " xmlns=\"\"";

    directly after this: if ($unqualified && $use == 'literal') {

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP