2013-09-26 49 views
0

我试图用肥皂向另一台服务器发送用户注册。我用DOMdocument创建了一个xml文件,而不是saveXML文件后我运行的是soap,它应该返回一个带有注册ID的xml以及我在xml中发送的所有数据。 但肥皂返回未知错误。正是这个:stdClass Object ([RegisztracioInsResult] => stdClass Object ([any] => 5Unknown error))用soap发送XML返回unknown unknown rerror

这就是我如何发送我的XML。

/*xml creation with DOMdocument*/ 
$xml = saveXML(); 
$url = 'http://mx.biopont.com/services/Vision.asmx?wsdl'; 
$trace = '1'; 
$client = new SoapClient($url, array('trace' => $trace, "exceptions" => 0, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); 
$params = $client->RegisztracioIns(array('xml' => $xml)); 
$print_r($params); 

如果我点击RegisztracioIns服务在此URL http://mx.biopont.com/services/Vision.asmx说明它表明我:

POST /services/Vision.asmx HTTP/1.1 
Host: mx.biopont.com 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://mx.biopont.com/services/RegisztracioIns" 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <RegisztracioIns xmlns="http://mx.biopont.com/services/"> 
     <xml>string</xml> 
    </RegisztracioIns> 
    </soap:Body> 
</soap:Envelope> 

根据这一点,我认为我正确的,但也许做上传没有我不用肥皂没有太多经验。

有什么我失踪?我也尝试将xml保存到我的服务器上,而不是使用file_get_contents()获取内容。但结果是一样的。

回答

0

你应该能够做这样的事情:

$res = $client->__soapCall('RegisztracioIns', array('xml'=>'my string to send')); 

要让WSDL包裹'my string to send'在适当的标签。

您正在做类似的事情,但我不认为wsdl实际上正在包装您尝试传递的字符串,并且没有传递任何内容,导致发生未知错误。

您可以使用$client->__getLastRequest();检查传出的xml。

(此外,你必须在你的代码一个小错字就上线应该是print_r($params);

如果做不到这一点,你可以尝试自己编写使用SoapVar() and setting the type to XSD_ANYXML的XML。

当wsdl为你包装所有东西时,它似乎比较干净,但它比在墙上敲击你的头好,直到它完成。

我试图用你的wsdl做到这一点。试试这个:

$wsdl = "http://mx.biopont.com/services/Vision.asmx?wsdl"; 
$client = new SoapClient($wsdl, array( 'soap_version' => SOAP_1_1, 
            'trace' => true, 
            )); 
try { 

$xml = "<RegisztracioIns xmlns='http://mx.biopont.com/services/'> 
      <xml>string</xml> 
     </RegisztracioIns>"; 

$args= array(new SoapVar($xml, XSD_ANYXML)); 

$res = $client->__soapCall('RegisztracioIns', $args); 
var_dump($res); 

} catch (SoapFault $e) { 

echo "Error: {$e}"; 

} 
print_r($client->__getLastRequest()); 
print_r($client->__getLastResponse()); 

我不能准确读取我得到的回应,因为它是匈牙利(我认为?)。所以让我知道这是否适合你。

相关问题