0

PHPNusoapを使用して簡単なWebサービスを作成しました。正しく機能しますが、欠落しているのは、デフォルトのxmlns属性を応答タグに追加することだけです。

これが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>

コードは次のとおりです。

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

どんな助けでも大歓迎です。

4

1 に答える 1

1

私はこれが特にエレガントであるとは言いませんが、私の場合はうまくいきました:

私はnusoap.phpにアクセスし、この行にコメントしました(私にとっては5925行目)。

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

この直後:if($ unqualified && $ use =='literal'){

于 2010-08-24T21:14:23.330 に答える