Hallo,
ich versuche mich gerade in Webservices einzuarbeiten - nach dem, was ich bisher so gelesen habe, scheint das - bis auf die WSDL auch kein großes Thema zu sein.
Ich habe momentan folgendes Problem:
Wenn ich meinen Server mit der Zweiten Funktion (sayBallo) teste, wird anscheindend intern die erste Funktion (sayHallo) aufgerufen - und dementsprechend ein ungültiges Ergebnis (Objekt statt String) generiert.
Wo ist der Haken?
Mein Server:
PHP-Code:
<?php
class Baum {
public $Wer;
public $Wann;
public $Was;
function __construct() {
$this->Wann='2010';
$this->Was='alles';
$this->Wer='ich';
}
}
function sayHallo($wer){
$mybaum=new Baum();
return $mybaum;
}
function sayBallo($param) {
return $param->Wer.'|Tut';
}
$myServer = new SoapServer("Komplex.wsdl");
$myServer->addFunction(array("sayBallo", "sayHallo"));
$myServer->handle();
?>
Meine WSDL:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ubuntu/~thomas/WSDL1/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Komplex" targetNamespace="http://ubuntu/~thomas/WSDL1/">
<wsdl:types>
<xsd:schema targetNamespace="http://ubuntu/~thomas/WSDL1/">
<xsd:element name="sayHalloType">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Wer" type="xsd:string" />
<xsd:element name="Wann" type="xsd:int"></xsd:element>
<xsd:element name="Was" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="sayBalloResponse1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="sayBalloResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element></xsd:schema>
</wsdl:types>
<wsdl:message name="sayHalloResponse">
<wsdl:part element="tns:sayHalloType" name="MyResponse"/>
</wsdl:message>
<wsdl:message name="sayHalloRequest1">
<wsdl:part name="MyInput" element="tns:sayHalloType"></wsdl:part>
</wsdl:message>
<wsdl:message name="sayBalloRequest">
<wsdl:part name="MyOtherInput" element="tns:sayHalloType"></wsdl:part>
</wsdl:message>
<wsdl:message name="sayBalloResponse">
<wsdl:part name="MyRes" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:portType name="Komplex">
<wsdl:operation name="sayHallo">
<wsdl:input message="tns:sayHalloRequest1"></wsdl:input>
<wsdl:output message="tns:sayHalloResponse"/>
</wsdl:operation>
<wsdl:operation name="sayBallo">
<wsdl:input message="tns:sayBalloRequest"></wsdl:input>
<wsdl:output message="tns:sayBalloResponse"></wsdl:output>
</wsdl:operation></wsdl:portType>
<wsdl:binding name="KomplexSOAP" type="tns:Komplex">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="sayHallo">
<soap:operation
soapAction="http://ubuntu/~thomas/WSDL1/sayHallo" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="sayBallo">
<soap:operation
soapAction="http://ubuntu/~thomas/WSDL1/sayBallo" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Komplex">
<wsdl:port binding="tns:KomplexSOAP" name="KomplexSOAP">
<soap:address location="http://ubuntu/~thomas/WSDL1/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Danke schonmal
Thomasch