SOAP client connecting to .net webservice

[email protected] (Milo van der Linden)
Newsgroups php.soap
Message-ID <[email protected]>
Hello list!

I am new to php SOAP and have an urgent question.

I am trying to connect to a webservice that is written in ASP.net.

The request I have to compose needs to be:

<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:itw="http://www.itworks.nl/">
    <soapenv:Header>
       <itw:AuthenticationHeader>
          <itw:Username>milo</itw:Username>
          <itw:PasswordHash>111</itw:PasswordHash>
          <itw:Database>?</itw:Database>
       </itw:AuthenticationHeader>
    </soapenv:Header>
    <soapenv:Body>
       <itw:Hello>
          <itw:yourName>T. Estuser</itw:yourName>
       </itw:Hello>
    </soapenv:Body>
</soapenv:Envelope>

And up till now I have written the following code, it includes header 
authentication or is supposed to..:

<?php
error_reporting(E_ALL);

$ini = ini_set("soap.wsdl_cache_enabled","0");
$client = new 
SoapClient("http://10.0.0.56:81/wssoilution/wsSoilution.asmx?WSDL",
   array('location' => 
'http://10.0.0.56:81/wssoilution/wsSoilution.asmx', 'uri' => 'itw', 
'trace' => 1));


var_dump($client->__getFunctions());
var_dump($client->__getTypes());

$x["Username"]="milo";
$x["PasswordHash"]="111";
$x["Database"]="?";

$x=new SoapVar($x,SOAP_ENC_OBJECT);
$y["AuthenticationHeader"]=$x;
$y=new SoapVar($y,SOAP_ENC_OBJECT);

$header=new SoapHeader("",'AuthenticationHeader',$y);
$client->__setSoapHeaders(array($header));


$params2 = array('yourName'=> 'T.Estuser');

$result2 = $client->Hello($params2);

?>



The error I am recieving is: Fatal error SoapHeader:SoapHeader(): 
Invalid parameters. Invalid namespace in soaptest.php on line 20

I cannot figure out how to set the namespace parameters!

Any help is appreciated.

Kind regards!

Milo
wsSoilution.asmx.WSDL (text/xml, 3.7 KB)
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.itworks.nl/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.itworks.nl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.itworks.nl/">
      <s:element name="Hello">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="yourName" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="HelloResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="HelloResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="AuthenticationHeader" type="tns:AuthenticationHeader" />
      <s:complexType name="AuthenticationHeader">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="PasswordHash" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Database" type="s:string" />
        </s:sequence>
        <s:anyAttribute />
      </s:complexType>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="HelloSoapIn">
    <wsdl:part name="parameters" element="tns:Hello" />
  </wsdl:message>
  <wsdl:message name="HelloSoapOut">
    <wsdl:part name="parameters" element="tns:HelloResponse" />
  </wsdl:message>
  <wsdl:message name="HelloAuthenticationHeader">
    <wsdl:part name="AuthenticationHeader" element="tns:AuthenticationHeader" />
  </wsdl:message>
  <wsdl:portType name="ServiceSoap">
    <wsdl:operation name="Hello">
      <wsdl:input message="tns:HelloSoapIn" />
      <wsdl:output message="tns:HelloSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="Hello">
      <soap:operation soapAction="http://www.itworks.nl/Hello" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
        <soap:header message="tns:HelloAuthenticationHeader" part="AuthenticationHeader" use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="Hello">
      <soap12:operation soapAction="http://www.itworks.nl/Hello" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
        <soap12:header message="tns:HelloAuthenticationHeader" part="AuthenticationHeader" use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="Service">
    <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
      <soap:address location="http://10.0.0.56:81/wssoilution/wsSoilution.asmx" />
    </wsdl:port>
    <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
      <soap12:address location="http://10.0.0.56:81/wssoilution/wsSoilution.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.