2017-05-31 1 views
0

Ich habe Probleme beim Erstellen einer WSDL-Datei für meine Hellowold PHP SoapServer.Build WSDL-Datei für Hallo Welt 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> 

ich Erfolg machen SOAP-Server gehabt haben, die bis Sie arbeiten versuchen, sie gegen eine WSDL-Datei zu validieren. Mein Ziel ist es, ein sehr einfaches "Hallo Welt" -Beispiel mit einer validierten WSDL-Datei zu erstellen.

soapUI gibt mir den Fehler:

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

Wie ich die WSDL-Datei nicht aktualisieren, so dass ich diesen Fehler nicht erhalten.

danke.

Antwort

0

Wenn jemand auf diese Frage stolpert. Bitte gehen Sie über diese IBM Website, die ein wenig technisch ist, aber sie enthält alle grundlegenden Informationen, die Sie möglicherweise benötigen, um mit SOAP- und WSDL-Dateien zu beginnen. Web Services Description Language (WSDL)

Ich bin sicher, dass die folgenden WSDL besser gemacht werden könnte, aber es funktioniert (validiert in .net)

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:tns="http://ws.apache.org/axis2" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://ws.apache.org/axis2"> 
     <wsdl:types> 
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://org.apache.axis2/xsd" elementFormDefault="unqualified" attributeFormDefault="unqualified"> 
       <xs:element name="helloRequest"> 
        <xs:complexType> 
         <xs:sequence> 
          <xs:element name="name" nillable="true" type="xs:string"/> 
         </xs:sequence> 
        </xs:complexType> 
       </xs:element> 
       <xs:element name="helloResponse"> 
        <xs:complexType> 
         <xs:sequence> 
          <xs:element type="xs:string" name="content" /> 
          <xs:element type="xs:date" name="endDate" /> 
          <xs:element type="xs:date" name="startDate" /> 
         </xs:sequence> 
        </xs:complexType> 
       </xs:element> 
      </xs:schema> 
     </wsdl:types> 
     <wsdl:message name="helloRequestMessage"> 
      <wsdl:part name="part1" element="ns1:helloRequest"/> 
     </wsdl:message> 
     <wsdl:message name="helloResponseMessage"> 
      <wsdl:part name="part1" element="ns1:helloResponse"/> 
     </wsdl:message> 
     <wsdl:portType name="helloPortType"> 
      <wsdl:operation name="hello"> 
       <wsdl:input message="tns:helloRequestMessage"/> 
       <wsdl:output message="tns:helloResponseMessage"/> 
      </wsdl:operation> 
     </wsdl:portType> 
     <wsdl:binding name="helloBinding" type="tns:helloPortType"> 
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
      <wsdl:operation name="hello"> 
       <soap:operation soapAction="hello" style="document" /> 
       <wsdl:input> 
        <soap:body use="literal" 
          namespace="http://example.com:8080/wsdl.php" /> 
       </wsdl:input> 
       <wsdl:output> 
        <soap:body use="literal" 
          namespace="http://example.com:8080/wsdl.php" /> 
       </wsdl:output> 
      </wsdl:operation> 
     </wsdl:binding> 
     <wsdl:service name="helloService"> 
      <wsdl:port name="helloPort" binding="tns:helloBinding"> 
       <soap:address location="http://example.com:8080/wsdl.php"/> 
      </wsdl:port> 
     </wsdl:service> 
    </wsdl:definitions>