2010-07-23 88 views
1

我已經使用PHP創建簡單的SOAP服務器,使用的WSDL是:http://fromyourdesign.com/webapp/wsdl/fromyourdesign.wsdlSOAP響應命名空間問題

響應即時得到具有對LoginResponse標籤不匹配的命名空間:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://roomplanner.icovia.com/pci"> 
    <SOAP-ENV:Body> 
    <ns1:LoginResponse xsi:type="http://roomplanner.icovia.com/pci"> <<<==== This shoud be <LoginResponse xmlns="http://roomplanner.icovia.com/pci"> 
     <LoginResult> 
     <register> 
      <customer>Rajat Teotia</customer> 
     </register> 
     </LoginResult> 
    </ns1:LoginResponse> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

代碼很簡單肥皂服務器是:

<?php 

class Login { 
public function Login($username, $password) { 
    $ns = 'http://roomplanner.icovia.com/pci'; 
    $LoginResponse = new StdClass(); 
    $LoginResponse->LoginResult->register->customer = 'Rajat Teotia'; 
    return new SoapVar ($LoginResponse, SOAP_ENC_OBJECT, $ns); 
} 
} 
$fydWsdl = "http://www.fromyourdesign.com/webapp/wsdl/fromyourdesign.wsdl"; 
ini_set ("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache 
$server = new SoapServer ($fydWsdl); 
$server->setClass ("Login"); 
$server->handle(); 
?> 

可以採取什麼措施來解決此問題。提前致謝。

Rajat

+1

命名空間是第四個參數,而不是第三個參數 – Wrikken 2010-07-23 22:55:29

回答

2

似乎,您的代碼中有錯誤的參數列表。命名空間應該是第四個參數,而不是第三個參數。

SoapVar :: SoapVar(字符串$數據,串$編碼[,字符串$ TYPE_NAME [,字符串$ type_namespace [,字符串$節點名稱[,字符串$ node_namespace]]]])

問候 儒略