473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2599

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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.