使用.net和nusoap的Web服务

时间:2011-02-17 19:44:19

标签: php web-services nusoap

我正在使用nusoap连接到.net服务,但是我收到错误“注意:未定义的变量:第54行的C:\ xampplite \ htdocs \ newsoap \ searchwwcc.php中的HEADER

致命错误:未捕获的SoapFault异常:[客户端]函数(“serializeEnvelope”)在C:\ xampplite \ htdocs \ newsoap \ searchwwcc.php中不是此服务的有效方法:54堆栈跟踪:#0 [内部函数]:SoapClient-> __ call('serializeEnvelo ...',Array)#1 C:\ xampplite \ htdocs \ newsoap \ searchwwcc.php(54):SoapClient-> serializeEnvelope('

以下是我正在使用的参考代码


require_once('lib/nusoap.php');


$serverpath ='https://service.website.net/ws/bridge.asmx?wsdl';

$SOAPClient =  new soapclient($serverpath);


$SOAPACTION  = "http://connect2.askadmissions.net/webservices/GetContact";
$BODY='<?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>
    <GetContact xmlns="http://service.website.net/webservices/">
        <ClientName>clientname</ClientName>
        <PassKey>*******</PassKey>
        <SearchCriteriaXml>
            <![CDATA[
                <attributes>
                    <attribute>
                        <name>email</name>
                        <value>name@name.com</value>
                        <operator>equals</operator>
                    </attribute>
                </attributes>
            ]]>
        </SearchCriteriaXml>
        <AttributesXml>
            <![CDATA[
                <attributes>
                    <attribute>
                        <name>firstname</name>
                    </attribute>
                    <attribute>
                        <name>lastname</name>
                    </attribute>
                </attributes>
            ]]>
        </AttributesXml>
    </GetContact>
  </soap:Body>
</soap:Envelope>';


 $SOAPMESSAGE =  $SOAPClient->serializeEnvelope($BODY,$HEADER,array(),'document', 'literal');
 $RESULT = $SOAPClient->send($BODY, $SOAPACTION);


echo  $SOAPClient->response;

1 个答案:

答案 0 :(得分:4)

我发现了什么问题:

我换线:

$SOAPClient =  new soapclient($serverpath);

$SOAPClient =  new nusoap_client($serverpath);

我得到了哪个修正错误,它开始给我空白页面。我发现空白页面是因为没有安装curl。

使用以下代码来回显错误:

$soapError = $SOAPClient->getError();
if (! empty($soapError)) {
    $errorMessage = 'SOAPClient failed: ' . $soapError;
    throw new Exception($errorMessage);
}

毕竟开始工作后我得到了警告:

Notice: Undefined property: nusoap_client::$operation in C:\xampplite\htdocs\newsoap\lib\nusoap.php on line 7674

我去了nusoap.php,然后插入了这行:

if(empty($this->operation)) {
   $this->operation = "";
}