NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How to declare sub complexType?


Joined: 21 Apr 2008
Posts: 10
Reply with quote
Hi,

I am creating nuSOAP webservice and I want something like this in my wsdl.


Code:

  <xs:complexType name="mainType">
      <xs:sequence>
         <xs:element name="Desc" maxOccurs="unbounded">
          <xs:complexType>
              <xs:sequence>
                  <xs:element name="TypeX" type="typeXTYPE" />
                  <xs:element name="TypeY" type="typeYTYPE" />
              </xs:sequence>
          </xs:complexType>
         </xs:element>
      </xs:sequence>
  </xs:complexType>


I know how to addComplexType and addSimpleType but I could not figureout how to do above.

I know its very basic question and many of you would be knowing it.

Thanks in advance,

Regards,

Dave
View user's profileFind all posts by naimish_hitSend private message


Joined: 03 Dec 2005
Posts: 17
Reply with quote
I'm not really sure, but I think you need two ComplexTypes to realize this.
I solved such a problem this way.

Code:

<?php
// This is the base type
$el = array(
   'aNormalString' => array(
      'name' => 'aNormalString',
      'type' => 'xsd:string'),
   'aDateTimeValue' => array(
      'name' => 'aDateTimeValue',
      'type' => 'xsd:dateTime'),
   'id' => array(
      'name' => 'id',
      'type' => 'xsd:int')
);
$server->wsdl->addComplexType('MyDataType','complexType','struct','all','',$el);


// This is a collection (array) of the base type
$server->wsdl->addComplexType(
   'MyDataTypeCollection',
   'complexType',
   'array',
   '',
   'SOAP-ENC:Array',
   array(),
   array(
      array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:MyDataType[]')
   ),
   'tns:MyDataType'
);

?>
View user's profileFind all posts by godsfatherSend private messageICQ Number


Joined: 21 Apr 2008
Posts: 10
Reply with quote
Hi,

Thanks for your help..

I tried your solution but it gives output something like this, which is not according what I want. I want exactly same output that I mentioned in my post.

Code:

- <xsd:complexType name="MyDataType">
- <xsd:all>
  <xsd:element name="aNormalString" type="xsd:string" />
  <xsd:element name="aDateTimeValue" type="xsd:dateTime" />
  <xsd:element name="id" type="xsd:int" />
  </xsd:all>
  </xsd:complexType>
- <xsd:complexType name="MyDataTypeCollection">
- <xsd:complexContent>
- <xsd:restriction base="SOAP-ENC:Array">
  <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:MyDataType[]" />
  </xsd:restriction>
  </xsd:complexContent>
  </xsd:complexType>


Regards,

Dave
View user's profileFind all posts by naimish_hitSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Quote:
I want exactly same output

SOAP is quite a flexible standard. You may achieve exactly the same results with a bit different definitions. Why do you need exactly same wsdl?

Anyway, feel free to check this great article http://www.scottnichol.com/nusoapprogwsdl.htm
and "Defining New Data Structures" topic in particular.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 21 Apr 2008
Posts: 10
Reply with quote
Hi,

Right now we are doing POC (Proof Of Concept) and this is client's requirement. They want exactly same output.

Regards,

Naimish R. Dave
View user's profileFind all posts by naimish_hitSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
it's not mandatory to have nusoap generating WSDL for you. If you know the endpoints, you can create WSDL yourself with content that matches your requirements.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
How to declare sub complexType?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic