1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Converting xsd to php nuSoap

Discussion in 'PHP' started by bledileka, Apr 17, 2012.

  1. #1
    hello guys,
    im new in wsdl so i don't really know all about xsd's or wsdl's.
    i have some client xsd who told me to build the webservice using the xsd schema. As i am familiar with php i started using nusoap as it seems to be much easier to start.
    I am told that i must use first contract method, my understanding is that the web servise i build would have the same methods and classes the client xsd explains, and the client with send messages to my WS using the methods in it. Am i right ?

    so my first xsd looks like this:
    
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:np="path_here" targetNamespace="path_here" elementFormDefault="unqualified" attributeFormDefault="unqualified">
    	<xs:include schemaLocation="types.xsd"/>
    	<xs:element name="systemup">
    		<xs:annotation>
    			<xs:documentation>some text here</xs:documentation>
    		</xs:annotation>
    		<xs:complexType>
    			<xs:sequence>
    				<xs:element name="version" type="np:version"/>
    				<xs:element name="idnumber" type="np:idnumber"/>
    				<xs:element name="datetime" type="xs:dateTime"/>
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    </xs:schema>
    
    Code (markup):
    and my php code for this:
    
    $server->wsdl->addSimpleType('version','xsd:string','SimpleType','struct',array());
    $server->wsdl->addSimpleType('idnumber','xsd:string','SimpleType','struct');
    
    $server->wsdl->addComplexType('systemup','complexType','struct','all','',
        array(
    		'version' => array('name' => 'version', 'type' => 'tns:version'),
    		'idnumber' => array('name' => 'idnumber', 'type' => 'tns:idnumber'),
    		'datetime' => array('name' => 'datetime', 'type' => 'xsd:dateTime')
        )
    );
    
    $server->register('systemup', array(
        'version' => 'tns:version', 
    	'idnumber' => 'tns:idnumber',
    	'datetime' => 'xsd:dateTime'), array(), $namespace, $soapaction."/systemup", 'rpc', 'encoded','Check if the system is up'); 
    
    PHP:
    Is this the way how it is done ? Do you have any suggestions or anything to add ?

    what about SimpleTypes that has more than one property as:
    
    <xs:simpleType name="testid">
    		<xs:restriction base="xs:string">
    			<xs:minLength value="1"/>
    			<xs:maxLength value="4"/>
    		</xs:restriction>
    </xs:simpleType>
    
    Code (markup):
    how it can be defined in nuSoap ??

    Any help would be very precious. Thank you in advance.
     
    bledileka, Apr 17, 2012 IP