简体   繁体   中英

Web Service with .net and nusoap

I am using nusoap to connect to .net service, but i get error "Notice: Undefined variable: HEADER in C:\\xampplite\\htdocs\\newsoap\\searchwwcc.php on line 54

Fatal error: Uncaught SoapFault exception: [Client] Function ("serializeEnvelope") is not a valid method for this service in C:\\xampplite\\htdocs\\newsoap\\searchwwcc.php:54 Stack trace: #0 [internal function]: SoapClient->__call('serializeEnvelo...', Array) #1 C:\\xampplite\\htdocs\\newsoap\\searchwwcc.php(54): SoapClient->serializeEnvelope('

Here is reference code what i am using


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;

I found out what was wrong :

i change line :

$SOAPClient =  new soapclient($serverpath);

to

$SOAPClient =  new nusoap_client($serverpath);

Which fixed error i was getting and it started giving me blank page. I found blank page was because curl was not installed.

Used following code to echo error:

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

After all started working i was getting warning :

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

I went to nusoap.php and before that line i inserted :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM