2

文字列を返す非常に単純なWebサービスがあります(その時点でハードコードされています)。SOAPペイロードの解析中にエラーが発生し続けます:予約済みXML名。

WSDLを問題なく表示できます(ファイアウォールの内部/背後にあるため、提供するリンクはありません)。

これは、私のメソッドを呼び出した後のNuSOAPクライアントの部分的なダンプです。

public 'request' => string 'POST myinternalhost.ca/ws.php HTTP/1.0
Host: myinternalhost.ca:443
User-Agent: NuSOAP/0.7.3 (1.114)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 510

<?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="htt'... (length=716)

public 'response' => string 'HTTP/1.1 200 OK
Date: Tue, 19 Jun 2012 18:43:10 GMT
Server: Apache/2.0.59 (Win32) DAV/2 mod_ssl/2.0.59 OpenSSL/0.9.8e mod_auth_sspi/1.0.4 PHP/5.2.3
X-Powered-By: PHP/5.2.3
X-SOAP-Server: NuSOAP/0.7.3 (1.114)
Content-Length: 470
Connection: close
Content-Type: text/xml; charset=ISO-8859-1

     <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope 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-i'... (length=769)

  public 'responseData' => string '  <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope 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><ns1:vms_ws_list_filesResponse xmlns:ns1="http://tempuri.org"><return xsi:type="xsd:string">SomeText</return></ns1:vms_ws_list_filesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>' (length=470)

public 'error_str' => string 'XML error parsing SOAP payload on line 1: Reserved XML Name' (length=59)

SOAP本体には、「SomeText」が表示されます。これは、次の1つのメソッドのみを含むWebサービスから返されるハードコードされたコンテンツです。

$server->register('vms_ws_list_files',
  array('password' => 'xsd:string'),      // Password check
  array('return' => 'xsd:string'),     // Output parameters
    $ns,                                  // namespace
    $ns . '#vms_ws_list_files',                 // soapaction
    'rpc',                                // style
    'encoded',                            // use
    'Get list of files on disk'                       // documentation
  );

...

function vms_ws_list_files($password){
    global $site;
    // Check password
    if ($password != 'myHardCodedPwdForTesting') {
        return new soap_fault('Wrong password!', '', '');
    }
    $out = "SomeText";

    return $out;
}

私の場合、ポート443は内部/テストであるため、保護されていません。

4

3 に答える 3

6

前に空白を削除する<?xml、機能します。trimできない場合は、解釈する前に、nusoapクラスを応答に変更/拡張することができます。<?phpほとんどの場合、余分な空白は&?>タグの外側の偶発的な空白に由来します。

于 2012-06-19T19:05:31.707 に答える
5

nusoap.phpに次の行を追加します。

$ this-> responseData = Trim($ this-> responseData);

この行の前:

$ this-> parseResponse($ http-> incoming_headers、trim($ this-> responseData));を返します。

私の同じ問題を解決しました

于 2013-03-24T21:29:08.097 に答える
1

私のコードでは、ポルトガル語のBRには非常に特殊な文字、引用符があり、タグを正しく閉じなかったため、XMLの形式が不十分でした。コードの最後に、戻り値であるXMLが表示され、次のサイトでチェックが行われました:http: //www.xmlvalidation.com/ その後、彼は仕事に戻りました。

于 2016-02-20T02:11:44.490 に答える