472,364 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,364 software developers and data experts.

PHP SOAP extension complex types and PHP classes

Hi everyone,

I wonder how is it possible to make PHP SOAP extension convert the
returned complex type to an instance of one of my classes.

Here I give you a short example:

complexTest.wsdl:

<?xml version="1.0" encoding="UTF-8"?>
<definitions
name="complexTest"
targetNamespace="http://www.mydomain.com/complexTest.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.mydomain.com/complexTest.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsd1="http://localhost/soapTypeTest/complexTest.xsd">
<types>
<xsd:schema

targetNamespace="http://localhost/soapTypeTest/complexTest.xsd"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.mydomain.com/complexTest.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsd1="http://localhost/soapTypeTest/complexTest.xsd">
<xsd:complexType name="TopicData">
<xsd:all>
<xsd:element maxOccurs="1" minOccurs="0"
name="topicId" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0"
name="topicTypeId" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0"
name="topicName" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0"
name="modifiedTs" type="xsd:dateTime"/>
<xsd:element maxOccurs="1" minOccurs="0"
name="createdTs" type="xsd:dateTime"/>
<xsd:element maxOccurs="1" minOccurs="0"
name="dataType" type="xsd:string"/>
<xsd:element
maxOccurs="1"
minOccurs="0"
name="dataValue"
type="xsd:base64Binary"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</types>
<message name="TopicData">
<part name="TopicData" type="xsd1:TopicData"/>
</message>
<portType name="complexTestPortType">
<operation name="getTopic">
<input message="tns:TopicData"/>
<output message="tns:TopicData"/>
</operation>
</portType>
<binding name="complexTestBinding" type="tns:complexTestPortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getTopic">
<soap:operation
soapAction="complexTest:complexTestPortType#getTop ic"/>
<input>
<mime:multipartRelated> </mime:multipartRelated>
</input>
<output>
<soap:body

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://www.taox.com/complexTest/binding"
use="encoded"/>
</output>
</operation>
</binding>
<service name="complexTest">
<port binding="tns:complexTestBinding" name="complexTestPort">
<soap:address
location="http://localhost/soapTypeTest/server.php"/>
</port>
</service>
</definitions>

server.php:

<?php

ini_set('soap.wsdl_cache_enabled', 0);

class TopicData {
var $topicId;
var $topicTypeId;
var $topicName;
var $modifiedTs;
var $createdTs;
var $dataType;
var $dataValue;
}

class TestServer {
function getTopic($topicData) {
$topicData->topicName = $topicData->topicId . " topic";
$topicData->createdTs = time();

return $topicData;
}
}

$server = new SoapServer("complexTest.wsdl");
$server->setClass('TestServer');
$server->handle();

?>

client.php:

<?php

ini_set('soap.wsdl_cache_enabled', 0);

class TopicData {
var $topicId;
var $topicTypeId;
var $topicName;
var $modifiedTs;
var $createdTs;
var $dataType;
var $dataValue;
}

$topic = new TopicData;
$topic->topicId = 3;
$client = new
SoapClient("http://localhost/soapTypeTest/server.php?wsdl",
array('trace' => 1));
$outObj = $client->getTopic($topic);
var_dump($outObj);
var_export($client->__getLastRequest());
var_export($client->__getLastResponse());
?>

What I would like to see after running client.php is that $outObj is an
instance of TopicData. Now it is a stdClass. Any ideas? (beyond that,
createdTs should be a date type, not a string)
Thank you in advance,
David

Jul 17 '05 #1
0 2521

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: burdeen | last post by:
I've been trying to return an array with PHP5 soap. Is this not supported? or am i doing it wrong? Seems to return on the last element in the array. In my WSDL i've defined my return type as a...
3
by: Nimai Malle | last post by:
I have not had any luck searching for a simple, simple example that calls a method on an object given a SOAP string. Here's what I'm looking for (in pseudocode): string SOAPCall = "bla bla...
3
by: man-in-nature | last post by:
Hello, I have already read several existing posts about xsd:extension, but do not find something useful to my test case. I have one xml file and one xsd file. I can use a simple command line...
2
by: Paul Hale | last post by:
I have a vb.net web service and client that are both working fine. If someone wanted to consume our web service using .NET, no problem. Im a little confused on how non .NET clients would use the...
4
by: pepcag | last post by:
I used http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconalteringsoapmessageusingsoapextensions.asp as a template to create a very simple web method with soap...
6
by: john deviney | last post by:
I have a C#/.Net 1.1 client talking to a Java based web service. I need to insert a soap header on the client side which is expected on the server side. Currently, the Java ws provider, Axis, does...
3
by: JRey | last post by:
Does .Net generate the classes for Faults when they are specified in the WSDL. I tried defining them and then generating a proxy, and it did not appear to do it. On the Java side it did generate...
0
by: dex | last post by:
Hi, I'm trying use a webservice with PHP5 soap extension in WSDL mode. I generated the php classes using wsdl2php. The problem is that 'auth' member of loginRequest (witch is a complex type)...
1
by: Florian Grousset | last post by:
Hi, I'm trying to code a simple C# SOAP client wich query an Axis2 Java SOAP Server. Server side code has been generated from a WSDL file. SOAP requests and responses must both contain a simple...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.