Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with SOAP connectivity

Status
Not open for further replies.

TheObserver

Programmer
Mar 26, 2002
91
US
I need to connect via SOAP to a data provider. They require several pieces of information to authenticate against. The prescribe a header layout to facilitate this:
Code:
<soap:Header>
    <impl:email>test@mountainnews.com</impl:email>
    <impl:language>en</impl:language>
    <impl:metric>imp</impl:metric>
    <impl:token/>
    <impl:password>mypassword</impl:password>
    <impl:domain/>
  </soap:Header>
I have attempted to connect via NuSOAP with the following:
Code:
$client = new nusoap_client($this->wsdl_location, true);
		$headers = "
		 <soap:Header>
    	 <impl:email>".$myUserName."</impl:email>
    <impl:language>en-us</impl:language>
    <impl:metric>imp</impl:metric>
    <impl:token/>
    <impl:password>".$myPassWord."</impl:password>
    <impl:domain/>
  </soap:Header>";
$client->setHeaders($headers);
$client->call("getTokens");
I always get the following result for this code:

soapenv:Server: SOAPEnvelope must contain a body element which is either first or second child element of the SOAPEnvelope.

result: Array ( [faultcode] => soapenv:Server [faultstring] => unknown [detail] => )

If I go with the built in SoapClient capability with the following code:
Code:
        $client = new SoapClient($this->wsdl_location, 
        array('email'          => $myUserName,
              'password'       => $myPassWord,
        	  'metric'         => 'imp',
              'language'       => 'en-us',
              'domain'         => '',
              'token'          => ''));
$client->__call("getTokens");
With this code I always get the following result:

Caught exception: SOAP-ERROR: Parsing Schema: unexpected <sequence> in element


I have no control over the server and am only writing a client to connect up to it and pull some data. What am I doing wrong? This is driving me crazy!

Thanks for your time.


 
The SOAP header is a standard and the values you have given don't look corret to me.
The SOAP toolkits should hide all these detals from you.
 
I can only be sure on this. Suppose your prefix impl is defined as prefix to the uri [ignore]"[/ignore] (taken as an example), you have to set the headers like this.
[tt]
$headers = "
<impl:email xmlns:impl=[blue][ignore]'[/ignore][/blue]>".$myUserName."</impl:email>
<impl:language>en-us</impl:language>
<impl:metric>imp</impl:metric>
<impl:token/>
<impl:password>".$myPassWord."</impl:password>
<impl:domain/>";
[/tt]
Watch out what are taken out and what is added. Replace the uri (in blue colour) per info your provider specified. You can as well make it default without prefix - but that would change every line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top