[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
Re: Problem ConsumING .Net Web Service
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:
<WebMethod(Description:="Returns a DataSet, usefull if coding in .Net; Params Example: @id=1234567890;@abc=12345")> _
Public Function execProcedureAsDataSet(ByVal ProcNaam As String, ByVal params As String) As Data.DataSet
Dim dSet As New Data.DataSet("OK")
//Fill DataSet here
Return dSet
End Function
VB Code:
<WebMethod(Description:="Returns a XMLDataDocument, usefull if coding in other language; Params Example: @id=1234567890;@abc=12345")> _
Public Function execProcedureAsXmlDataDocument(ByVal ProcNaam As String, ByVal params As String) As System.Xml.XmlDataDocument
Return New System.Xml.XmlDataDocument(execProcedureAsDataSet(ProcNaam, params))
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