.NET interoperability continued...
| From: | Andrei Ivanov | Date: | Wed, 19 Feb 2003 15:49:14 +0000 |
| Subject: | .NET interoperability continued... | ||
| References: | 1 2 | Groups: | php.soap |
| Request: | Send a blank email to php-soap+get-432@lists.php.net to get a copy of this message | ||
Ok... after some struggling with this I ended up nowhere...
I will give more details, hoping someone will help me and show me what I
did wrong.
I created a class, categs_service, with a single method:
<?
require_once './objects.inc.php';
require_once 'SOAP/Server.php';
class categs_service {
var $categs;
var $langs;
function categs_service(){
$this->langs = array('ro', 'en');
$this->id = 0;
$this->id++;
foreach ($this->langs as $l){
$this->categs[$l][$this->id] = new categ($this->id, null, 'categ
'.$this->id.' '.$l, null);
}
}
function getCategs($pid, $lang){
return $this->categs[$lang];
}
}
$server = new SOAP_Server(array('style' => 'document', 'use' =>
'literal'));
$server = new SOAP_Server();
$server->_auto_translation = true;
$soapclass = new categs_service;
$server->addObjectMap($soapclass,'http://demo.dev.ro/soap/categs_service');
$server->bind('categs_service_document_literal.wsdl');
$server->service($HTTP_RAW_POST_DATA);
?>
and
class categ {
var $id;
var $pid;
var $name;
var $def;
var $page_count;
}
In c# and visual studio I've created almost identical objects and
generated the wsdl that I'm using for the php soap server, file which I
attached to this email.
The problem I think it is that the output generated by the php soap server
doesn't quite match the wsdl, which I think it should do:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns4="http://demo.dev.ro/soap/categs_service"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns4:getCategsResponse>
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[3]"
SOAP-ENC:offset="[0]">
<item>
<id xsi:type="xsd:int">1</id>
<pid/>
<name xsi:type="xsd:string">categ 1 ro</name>
<def/>
<page_count xsi:type="xsd:int">0</page_count>
<lang/>
<description/>
</item>
<item>
<id xsi:type="xsd:int">2</id>
<pid/>
<name xsi:type="xsd:string">categ 2 ro</name>
<def/>
<page_count xsi:type="xsd:int">0</page_count>
<lang/>
<description/>
</item>
</return>
</ns4:getCategsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I think that instead of SOAP-ENC:arrayType="xsd:anyType[3]" this should be
ArrayOfCateg, dunno for sure, I'm quite a beginer in xml.
Instead of return it should be getCategResponse and instead of item, it
should be getCategResult.
This is the output generated by the c# server:
<?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>
<getCategsResponse xmlns="http://demo.dev.ro/soap/categs_service">
<getCategsResult>
<Categ>
<id>int</id>
<pid>int</pid>
<name>string</name>
<def>int</def>
<description>string</description>
<page_count>int</page_count>
</Categ>
<Categ>
<id>int</id>
<pid>int</pid>
<name>string</name>
<def>int</def>
<description>string</description>
<page_count>int</page_count>
</Categ>
</getCategsResult>
</getCategsResponse>
</soap:Body>
</soap:Envelope>
I have even tried to replace getCategsResult with return and Categ with
item in the wsdl, and still the c# client doesn't like it. And even if it
did, I don't think it's normal that php doesn't create the xml the proper
way.
I hope I explained what I did clear enough. I'm a beginner in web services
and c# (and in this matter, even php). Please help me, what can I do ?
I've tried all the other combinations (document/encoded and rpc/encoded),
but they don't work either. I've read slides by Shane Caraveo from Dec 10,
2002, but they don't explain in detail the interoperability with .net.