Results 1 to 3 of 3

Thread: [RESOLVED] Problem ConsumING .Net Web Service

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    198

    Resolved [RESOLVED] Problem ConsumING .Net Web Service

    Hi All

    I was wondering how i would parse a .Net XmlDataDocument type in PHP.
    Is there some functionality in NuSoap?
    Is it better to change the return type of the webservice into XMLDocument?

    Thanks in advance, Figa

    The .Net XMLDataDocument looks like this:
    Code:
      <?xml version="1.0" encoding="utf-8" ?> 
    - <OK>
    - <Table>
      <Procedurenaam>Obj_All</Procedurenaam> 
      <Omschrijving>Alles van een Subject/Persoon met Postcode</Omschrijving> 
      <fullSearch>false</fullSearch> 
      </Table>
    - <Table>
      <Procedurenaam>Obj_All_id</Procedurenaam> 
      <Omschrijving>Helemaal niks</Omschrijving> 
      <fullSearch>false</fullSearch> 
      </Table>
    + <Table>
      <Procedurenaam>Obj_All_i</Procedurenaam> 
      <Omschrijving>Geen idee joh</Omschrijving> 
      <fullSearch>false</fullSearch> 
      </Table>
    + <Table>
      <Procedurenaam>get_Obj_Count</Procedurenaam> 
      <Omschrijving>Get aantal Objecten</Omschrijving> 
      <fullSearch>false</fullSearch> 
      </Table>
    + <Table>
      <Procedurenaam>Test</Procedurenaam> 
      <Omschrijving>Zoek Persoon op ID daarna op Postcode Huisnummer</Omschrijving> 
      <fullSearch>true</fullSearch> 
      </Table>
    + <Table>
      <Procedurenaam>Proc1</Procedurenaam> 
      <Omschrijving>Get Postcode en huisnummer</Omschrijving> 
      <fullSearch>false</fullSearch> 
      </Table>
    + <Table>
      <Procedurenaam>Proc2</Procedurenaam> 
      <Omschrijving>Get BSN en Achternaam</Omschrijving> 
      <fullSearch>true</fullSearch> 
      </Table>
    + <Table>
      <Procedurenaam>Obj_Kaart</Procedurenaam> 
      <Omschrijving>Get Objecten van Kaart</Omschrijving> 
      <fullSearch>false</fullSearch> 
      </Table>
    + <Table>
      <Procedurenaam>Pers_PC</Procedurenaam> 
      <Omschrijving>Get Persoon met postcode</Omschrijving> 
      <fullSearch>false</fullSearch> 
      </Table>
    + <Table>
      <Procedurenaam>Obj_Krt_Eignisnull</Procedurenaam> 
      <Omschrijving>Get Objecten van Kaart zonder eigenaar</Omschrijving> 
      <fullSearch>false</fullSearch> 
      </Table>
      </OK>
    The only thing i want to do is to display this data, what functionality in PHP can i use?

    Figa
    Last edited by figa; Feb 8th, 2007 at 10:31 AM.

  2. #2
    Junior Member
    Join Date
    Mar 2006
    Posts
    24

    Re: Problem ConsumING .Net Web Service

    U might try to use Pear XML package.

    http://pear.php.net/package/XML_Parser

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    198

    Lightbulb Re: Problem ConsumING .Net Web Service

    I found how to do it:

    My Webservice has some methods, some with and some without parameters. But there's a problem with consuming ASP.Net web services, but ill explain later.

    I designed it so i could return DataSets for .Net clients and XMLDataDocument for non . Net clients like PHP.

    These are 2 of the functions
    VB Code:
    1. <WebMethod(Description:="Returns a DataSet, usefull if coding in .Net; Params Example: @id=1234567890;@abc=12345")> _
    2.     Public Function execProcedureAsDataSet(ByVal ProcNaam As String, ByVal params As String) As Data.DataSet
    3.         Dim dSet As New Data.DataSet("OK")
    4.         //Fill DataSet here
    5.         Return dSet
    6.     End Function
    VB Code:
    1. <WebMethod(Description:="Returns a XMLDataDocument, usefull if coding in other language; Params Example: @id=1234567890;@abc=12345")> _
    2.     Public Function execProcedureAsXmlDataDocument(ByVal ProcNaam As String, ByVal params As String) As System.Xml.XmlDataDocument
    3.         Return New System.Xml.XmlDataDocument(execProcedureAsDataSet(ProcNaam, params))
    4.     End Function

    As you can see its one line of code, to change a dataset into a readable format for non .Net clients.
    Now for some code to consume a ASP.Net webservice from a PHP client, using nusoap.
    With parameters:
    Code:
    <html>
     <head>
      <title>PHP Test</title>
     </head>
     <body>
    
    <?php
    	require_once('lib\nusoap.php');
    	
    	$wsdl="http://localhost/nDP/Service.asmx?WSDL";
    	$client=new soapclient($wsdl,true);//'wsdl'
            $param=array('parameters'=>array('ProcNaam'=>'Obj_Kaart','params'=>'@kaart=1'));
    	$res = $client->call('execProcedureAsXmlDataDocument',$param); 
    echo "<pre>";
    var_dump($res);
    echo "</pre>";
    ?>
     </body>
    </html>
    Without parameters:
    Code:
    <html>
     <head>
      <title>PHP Test</title>
     </head>
     <body>
    
    <?php
    	require_once('lib\nusoap.php');
    	
    	$wsdl="http://localhost/nDP/Service.asmx?WSDL";
    	$client=new soapclient($wsdl,true);//'wsdl'
    	$res = $client->call('getProcedureListAsXmlDataDocument'); 
    echo "<pre>";
    var_dump($res);
    echo "</pre>";
    ?>
     </body>
    </html>
    As you can see the param variable is an array within an array, apperantly an ASP.Net webservice wants it this way.(Cost me a day to figure it out)

    Well i hope i saved someone else a lot of work.

    Cheers Figa
    Last edited by figa; Feb 9th, 2007 at 10:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width