List Info

Thread: Returning Data Objects to the client side




Returning Data Objects to the client side
user name
2007-12-27 08:31:12
Hello friends,

How can I return a Data Object to the client side?
I am using the SDO_DAS_XML to create the data object but I
cannot send
to the client the correct object.

I have tried this example (and a lot others):
http://www.ibm.com/developerworks/web/libr
ary/ws-soa-scasdo/index.html

My service file:
<?php
include "SCA/SCA.php";

/**
 * service
 * binding.soap
 *
 * location ht
tp://mydomain.com/SOA/Weather/WeatherService.php
 * types http://Weather http:/
/mydomain.com/SOA/Weather/AreasTypes.xsd
 * types http://Weather http://mydomain.com/SOA/Weather/TemperaturesTypes.xsd
 */
class WeatherService {
	/**
     * param Areas $Areas http://Weather
     * return Temperatures http://Weather
     */
    public function getTemperature($Areas) {
        $Temperatures = SCA::createDataObject('http://Weather',
'Temperatures');
        $Pair =
$Temperatures->createDataObject('entry');
        $Pair->state = 'CA';
        $Pair->temperature = 65;
        $Pair =
$Temperatures->createDataObject('entry');
        $Pair->state = 'UT';
        $Pair->temperature = 105;
        $Pair =
$Temperatures->createDataObject('entry');
        $Pair->state = 'ND';
        $Pair->temperature = -20;
        return $Temperatures;
    }
}
?>

My client file:
<?php
include "SCA/SCA.php";

$weather = SCA::getService('http://mydomain.com/
SOA/Weather/
WeatherService.php');

$Areas = $weather->createDataObject('http://Weather','Areas');
$area = $Areas->createDataObject('area');
$area->state = 'CA';
$area = $Areas->createDataObject('area');
$area->state = 'UT';
$area = $Areas->createDataObject('area');
$area->state = 'ND';
$Temperatures = $weather->getTemperature($Areas);

echo "Received temperatures from Web
service:<br>";
foreach($Temperatures->entry as $Pair)
    echo $Pair->state . ": " .
$Pair->temperature . "<br>";
?>

The AreasTypes.xsd:
<?xml version="1.0"
encoding="UTF-8"?>
<schema xmlnss=&qu
ot;http://www.w3.
org/2001/XMLSchema"
targetNamespace="http://Weather"
elementFormDefault="qualified">
	<complexType name="StateType">
		<sequence>
			<element name="state"
type="string"/>
		</sequence>
	</complexType>
	<element name="Areas">
		<complexType>
			<sequence>
				<element name="area"
type="ns1:StateType"
maxOccurs="unbounded"/>
			</sequence>
		</complexType>
	</element>
</schema>

The TemperaturesTypes.xsd:
<?xml version="1.0"
encoding="UTF-8"?>
<schema xmlnss=&qu
ot;http://www.w3.
org/2001/XMLSchema"
targetNamespace="http://Weather"
elementFormDefault="qualified">
	<complexType name="PairType">
		<sequence>
			<element name="state"
type="string"/>
			<element name="temperature"
type="float"/>
		</sequence>
	</complexType>
	<element name="Temperatures">
		<complexType>
			<sequence>
				<element name="entry"
type="ns1:PairType"
maxOccurs="unbounded"/>
			</sequence>
		</complexType>
	</element>
</schema>

The WSDL file:
<?xml version="1.0"
encoding="UTF-8"?>
<wsdl:definitions xmlns:tns2="http://WeatherService&quo
t;
xmlns:wsdl="http://schemas
.xmlsoap.org/wsdl/" xmlns:soap="http://
schemas.xmlsoap.org/wsdl/soap/" xmlnssi=&q
uot;http://www.w3.org/2001/
XMLSchema-instance" targetNamespace="http://WeatherService
">
  <wsdl:types>
    <xs:schema xmlnss=&qu
ot;http://www.w3.
org/2001/XMLSchema"
      xmlns:ns0="http://Weather"
      xmlns:ns1="http://Weather"
      targetNamespace="http://WeatherService&quo
t;
      elementFormDefault="qualified">
      <xs:import schemaLocation="http://mydomain.com/
SOA/Weather/
AreasTypes.xsd" namespace="http://Weather"/>
      <xs:import schemaLocation="http://mydomain.com/
SOA/Weather/
TemperaturesTypes.xsd" namespace="http://Weather"/>
      <xs:element name="getTemperature">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Areas"
type="ns1:Areas"/>

          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element
name="getTemperatureResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element
name="getTemperatureReturn"
type="ns1:Temperatures"/>
          </xs:sequence>
        </xs:complexType>

      </xs:element>
    </xs:schema>
  </wsdl:types>

  <wsdl:message
name="getTemperatureRequest">
    <wsdl:part name="getTemperatureRequest"
element="tns2:getTemperature"/>
  </wsdl:message>
  <wsdl:message
name="getTemperatureResponse">
    <wsdl:part name="return"
element="tns2:getTemperatureResponse"/>

  </wsdl:message>
  <wsdl:portType
name="WeatherServicePortType">
    <wsdl:operation name="getTemperature">
      <wsdl:input
message="tns2:getTemperatureRequest"/>
      <wsdl:output
message="tns2:getTemperatureResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="WeatherServiceBinding"
type="tns2:WeatherServicePortType">
    <soap:binding transport="http://sch
emas.xmlsoap.org/soap/http"
style="document"/>

    <wsdl:operation name="getTemperature">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>

  </wsdl:binding>
  <wsdl:service
name="WeatherServiceService">
    <wsdl:port name="WeatherServicePort"
binding="tns2:WeatherServiceBinding">
      <soap:address location="http://mydomain.com/
SOA/Weather/
WeatherService.php"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

<!-- this line identifies this file as WSDL generated by
SCA for PHP.
Do not remove -->


Can you tell me what I am doing wrong?

The next question is: How can I create a dynamic data object
returning
to the client a list of some information?

Thank you guys!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "phpsoa" group.
To post to this group, send email to phpsoagooglegroups.com
To unsubscribe from this group, send email to
phpsoa-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.co.uk/group/phpsoa?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Returning Data Objects to the client side
user name
2008-01-03 05:07:03


On 27 Dec 2007, 14:31, aouriques <mundopi...gmail.com> wrote:
> Hello friends,
>
> How can I return a Data Object to the client side?
> I am using the SDO_DAS_XML to create the data object
but I cannot send
> to the client the correct object.
>
> I have tried this example (and a lot others):http://www.ibm.com/developerworks/web/libr
ary/ws-soa-scasdo/index.html
>
> My service file:
> <?php
> include "SCA/SCA.php";
>
> /**
>  * service
>  * binding.soap
>  *
>  * locationht
tp://mydomain.com/SOA/Weather/WeatherService.php
>  * typeshttp://Weatherhttp://mydomain.com/SOA/Weather/AreasT
ypes.xsd
>  * typeshttp://Weatherhttp://mydomain.com/SOA/Weather
/TemperaturesTypes.xsd
>  */
> class WeatherService {
>         /**
>      * param Areas $Areashttp://Weather
>      * return Temperatureshttp://Weather
>      */
>     public function getTemperature($Areas) {
>         $Temperatures = SCA::createDataObject('http://Weather',
> 'Temperatures');
>         $Pair =
$Temperatures->createDataObject('entry');
>         $Pair->state = 'CA';
>         $Pair->temperature = 65;
>         $Pair =
$Temperatures->createDataObject('entry');
>         $Pair->state = 'UT';
>         $Pair->temperature = 105;
>         $Pair =
$Temperatures->createDataObject('entry');
>         $Pair->state = 'ND';
>         $Pair->temperature = -20;
>         return $Temperatures;
>     }}
>
> ?>
>
> My client file:
> <?php
> include "SCA/SCA.php";
>
> $weather = SCA::getService('http://mydomain.com/
SOA/Weather/
> WeatherService.php');
>
> $Areas = $weather->createDataObject('http://Weather','Areas');
> $area = $Areas->createDataObject('area');
> $area->state = 'CA';
> $area = $Areas->createDataObject('area');
> $area->state = 'UT';
> $area = $Areas->createDataObject('area');
> $area->state = 'ND';
> $Temperatures = $weather->getTemperature($Areas);
>
> echo "Received temperatures from Web
service:<br>";
> foreach($Temperatures->entry as $Pair)
>     echo $Pair->state . ": " .
$Pair->temperature . "<br>";
> ?>
>
> The AreasTypes.xsd:
> <?xml version="1.0"
encoding="UTF-8"?>
> <schema xmlnss=&qu
ot;http://www.w3.
org/2001/XMLSchema"
> targetNamespace="http://Weather"
elementFormDefault="qualified">
>         <complexType name="StateType">
>                 <sequence>
>                         <element
name="state" type="string"/>
>                 </sequence>
>         </complexType>
>         <element name="Areas">
>                 <complexType>
>                         <sequence>
>                                 <element
name="area" type="ns1:StateType"
maxOccurs="unbounded"/>
>                         </sequence>
>                 </complexType>
>         </element>
> </schema>
>
> The TemperaturesTypes.xsd:
> <?xml version="1.0"
encoding="UTF-8"?>
> <schema xmlnss=&qu
ot;http://www.w3.
org/2001/XMLSchema"
> targetNamespace="http://Weather"
elementFormDefault="qualified">
>         <complexType name="PairType">
>                 <sequence>
>                         <element
name="state" type="string"/>
>                         <element
name="temperature" type="float"/>
>                 </sequence>
>         </complexType>
>         <element name="Temperatures">
>                 <complexType>
>                         <sequence>
>                                 <element
name="entry" type="ns1:PairType"
maxOccurs="unbounded"/>
>                         </sequence>
>                 </complexType>
>         </element>
> </schema>
>
> The WSDL file:
> <?xml version="1.0"
encoding="UTF-8"?>
> <wsdl:definitions xmlns:tns2="http://WeatherService&quo
t;
> xmlns:wsdl="http://schemas
.xmlsoap.org/wsdl/" xmlns:soap="http://
> schemas.xmlsoap.org/wsdl/soap/" xmlnssi=&q
uot;http://www.w3.org/2001/
> XMLSchema-instance" targetNamespace="http://WeatherService
">
>   <wsdl:types>
>     <xs:schema xmlnss=&qu
ot;http://www.w3.
org/2001/XMLSchema"
>       xmlns:ns0="http://Weather"
>       xmlns:ns1="http://Weather"
>       targetNamespace="http://WeatherService&quo
t;
>       elementFormDefault="qualified">
>       <xs:import schemaLocation="http://mydomain.com/
SOA/Weather/
> AreasTypes.xsd" namespace="http://Weather"/>
>       <xs:import schemaLocation="http://mydomain.com/
SOA/Weather/
> TemperaturesTypes.xsd" namespace="http://Weather"/>
>       <xs:element
name="getTemperature">
>         <xs:complexType>
>           <xs:sequence>
>             <xs:element name="Areas"
type="ns1:Areas"/>
>
>           </xs:sequence>
>         </xs:complexType>
>       </xs:element>
>       <xs:element
name="getTemperatureResponse">
>         <xs:complexType>
>           <xs:sequence>
>             <xs:element
name="getTemperatureReturn"
> type="ns1:Temperatures"/>
>           </xs:sequence>
>         </xs:complexType>
>
>       </xs:element>
>     </xs:schema>
>   </wsdl:types>
>
>   <wsdl:message
name="getTemperatureRequest">
>     <wsdl:part
name="getTemperatureRequest"
> element="tns2:getTemperature"/>
>   </wsdl:message>
>   <wsdl:message
name="getTemperatureResponse">
>     <wsdl:part name="return"
element="tns2:getTemperatureResponse"/>
>
>   </wsdl:message>
>   <wsdl:portType
name="WeatherServicePortType">
>     <wsdl:operation
name="getTemperature">
>       <wsdl:input
message="tns2:getTemperatureRequest"/>
>       <wsdl:output
message="tns2:getTemperatureResponse"/>
>     </wsdl:operation>
>   </wsdl:portType>
>   <wsdl:binding
name="WeatherServiceBinding"
> type="tns2:WeatherServicePortType">
>     <soap:binding transport="http://sch
emas.xmlsoap.org/soap/http"
> style="document"/>
>
>     <wsdl:operation
name="getTemperature">
>       <soap:operation soapAction=""/>
>       <wsdl:input>
>         <soap:body use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>
>   </wsdl:binding>
>   <wsdl:service
name="WeatherServiceService">
>     <wsdl:port name="WeatherServicePort"
> binding="tns2:WeatherServiceBinding">
>       <soap:address location="http://mydomain.com/
SOA/Weather/
> WeatherService.php"/>
>     </wsdl:port>
>   </wsdl:service>
> </wsdl:definitions>
>
> <!-- this line identifies this file as WSDL
generated by SCA for PHP.
> Do not remove -->
>
> Can you tell me what I am doing wrong?
>
> The next question is: How can I create a dynamic data
object returning
> to the client a list of some information?
>
> Thank you guys!
Hi there

You should be able to do this and on the face of it your
code looks
good. Can you tell me....

1. What was the result of running it. An error? Just no
return data?
2. Did the input parameter ($Areas) get delivered
successfully?
3. What version of the code you are using?

We do return complex types in some of the samples, for
example,  [1].
Haven't run it for a while so will have to get set up and
give it a
spin to make sure it still works.

Regards

Simon

[1] http://cvs.php.ne
t/viewvc.cgi/pecl/sdo/examples/SCA/emailcontact/ContactServi
ce.php?view=markup
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "phpsoa" group.
To post to this group, send email to phpsoagooglegroups.com
To unsubscribe from this group, send email to
phpsoa-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.co.uk/group/phpsoa?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )