我在爲我的hellowold PHP soapserver創建WSDL文件時遇到了麻煩。爲hello world soapserver生成WSDL文件
Server代碼:
<?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>
我有那樣的工作,直到你嘗試驗證他們對WSDL文件成功使SOAP服務器。我的目標是創建一個非常基本的「Hello World」示例,並驗證WSDL文件。
的soapUI是給我的錯誤:
line 4: Expected element '[email protected]:foo:bar' instead of 'dataSet' here in element [email protected]:foo:bar line 7: Expected element '[email protected]:foo:bar' before the end of the content in element [email protected]:foo:bar
如何更新WSDL文件,這樣我沒有得到這個錯誤。
謝謝。