I am having trouble creating a WSDL file for my hellowold PHP soapserver.
Server code:
<?php
function hello($soapData) {
$finalresponse [] = new SoapVar ( $soapData->name, XSD_STRING, null, null, 'content' );
$finalresponse [] = new SoapVar ( "1980-01-01", XSD_DATE, null, null, 'endDate' );
$finalresponse [] = new SoapVar ( "1980-01-01", XSD_DATE, null, null, 'startDate' );
return new SoapVar ( $finalresponse, SOAP_ENC_OBJECT, null, null, "" );
}
ini_set ( "soap.wsdl_cache_enabled", "0" );
$server = new SoapServer ( "http://example.com:8080/wsdl.wsdl", array ('soap_version' => SOAP_1_2 ) );
$server->addFunction ( "hello" );
$server->handle ();
?>
WSDL.file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://example.com:8083/wsdl.php" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:foo" xmlns:S2="urn:foo:bar" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="hello" targetNamespace="urn:foo">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:foo:bar">
<element name="dataSet">
<complexType>
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="hello">
<complexType>
<sequence>
<element name="hello" nillable="true" type="xsd:string"/>
<element name="date" nillable="true" type="xsd:date"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
<element name="hello">
<complexType>
<sequence>
<element name="name" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="helloResponse">
<complexType>
<sequence>
<element ref="S2:dataSet"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="hello_hello">
<part name="parameters" element="S2:hello"/>
</message>
<message name="hello_helloResponse">
<part name="parameters" element="S2:helloResponse"/>
</message>
<portType name="helloObj">
<operation name="hello">
<input message="tns:hello_hello"/>
<output message="tns:hello_helloResponse"/>
</operation>
</portType>
<binding name="helloObj" type="tns:helloObj">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="hello">
<soap:operation soapAction="" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="helloService">
<port name="helloObj" binding="tns:helloObj">
<wsdl:documentation/>
<soap:address location="http://example.com:8083/wsdl.php"/>
</port>
</service>
</definitions>
I have had success making SOAP servers that work until you try to validate them against a WSDL file. My goal is to make a very basic "hello World" example, with WSDL file that validates.
soapUI is giving me the error:
line 4: Expected element 'dataSet@urn:foo:bar' instead of 'dataSet' here in element helloResponse@urn:foo:bar line 7: Expected element 'dataSet@urn:foo:bar' before the end of the content in element helloResponse@urn:foo:bar
How do I update the WSDL file so that i do not get this error.
thanks.