Hallo,
ich muss in meiner Firma eine Schnittstelle zwischen unserem und dem Ticketsystem eines anderen Unternehmens herstellen.
Das externe Unternehmen hat dazu einen WebService bereitgestellt welcher anfragen von unserer Seite verarbeiten soll.
Im folgenden habe ich einige Sachen durch z.B. xxx ersetzt.
Dabei habe ich gleiche namen immer mit gleichen werten ersetzt.
(Soll heißen xxx steht immer für z.B. google.de, während yyy für yahoo stehen könnte. Ich hoffe ich habe es verständlich ausgedrückt.)
zum Problem:
Mein Code scheint nicht den richtigen Request zu erzeugen, der erwartet wird.
Ich komme leider absolut nicht drauf, was ich machen muss damit der Request richtig erstellt wird.
was ich momentan tue: PHP-Code:
# Pfad zur .wsdl
$FileForWSDL = realpath('incidentservice.wsdl');
$client;
# Wenn .wsdl Pfad vorhanden
if($FileForWSDL){
# Verbindung zum WebService erstellen
$client = new SoapClient(
$FileForWSDL,
array('login' => "einLogin",
'password' => "einPasswort",
'location' => "https://yyy.xxx.de/incident-webservice/Event?wsdl=IncidentService.wsdl",
'uri' => "http://xxx.de/sbm/incident",
'trace' => 1
)
);
}else{
die('Destionation-URI for WSDL-File unreachable, try again later or check configuration.');
}
# Übergabewerte für Funktion
$createDocument->ticketid = "123456";
$createDocument->shortDescription = "Test Text";
try
{ );
# ausführen der Abfrage
$result = $client->__soapCall(
"createIncident",
array( NULL,
'create' => new SoapParam($createDocument, "create") ),
array( 'soapaction' => "")
);
}
catch(Exception $e)
{
echo ' <b>Error:</b> '.$e;
echo '<br/> <b>LastRequest:</b> '.$client->__getLastRequest();
echo '<br/> <b>LastRequestHead:</b> '.$client->__getLastRequestHeaders();
echo '<br/> <b>LastResponse:</b> '.$client->__getLastResponse();
echo '<br/> <b>LastResponseHead:</b> '.$client->__getLastResponseHeaders();
}
# Ausgabe der Rückmeldung
echo "<p>Result:</p>";
echo "<pre>";
@print_r($result);
echo "</pre>";
Der Request der erzeug wird, sieht folgendermaßen aus: Code:
<soap-env:envelope xmlns:ns1="http://xxx.de/sbm/incident"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:body>
<ns1:createincident>
<create>
<ticketid>123456</ticketid>
<shortdescription>Test Text</shortdescription>
</create>
</ns1:createincident>
</soap-env:body>
</soap-env:envelope>
Laut der Gegenseite sollte für die Aktion der Request folgendermaßen aussehen: Code:
<soap-env:Envelope xmlns:ns1="http://xxx.de/sbm/incident"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://www.eclipse.org/alf/schema/EventBase/1">
<soap-env:Body>
<ns1:createIncident>
<create>
<ns:ticketid>123456</ns:ticketid>
<ns:shortDescription>Test Text</ns:shortDescription>
</create>
</ns1:createIncident>
</soap-env:Body>
</soap-env:Envelope>
Zusätzlich bekam ich noch folgendes als Info:
Zitat:
soap-env:Envelope anstatt soap-env:envelope und soap-env:Body anstatt soap-env:Body
Für die eigentliche Nachricht müssen Sie den zusätzlichen Namespace xmlns:ns="http://www.eclipse.org/alf/schema/EventBase/1"
einbinden und diesen für shortDescription bzw. ticketid verwenden.
|
- Sind Requests "case-sensitive" ?
- Wie füge ich den zusätzlichen Namespace hinzu?
Außerdem erhalte ich als Response folgende Meldung: Code:
soap:ServerFault occurred while processing
Als die Gegenseite mein Request bei sich ausprobiert hat bekamen sie aber eine andere Meldung, und zwar:
Code:
soap:Server Current event not START_ELEMENT or END_ELEMENT
Keine Ahnung weswegen das so ist und ob es ausschlaggebend ist.
Ich könnte mir vorstellen das wenn mein Request passt, sich das eh erledigt hat.
Hier nochmal die "incidentservice.wsdl": Code:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="IncidentServiceService" targetNamespace="http://xxx.de/sbm/incident"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xxx.de/sbm/incident"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://www.eclipse.org/alf/schema/EventBase/1"
xmlns:tns="http://www.eclipse.org/alf/schema/EventBase/1" elementFormDefault="qualified"
targetNamespace="http://www.eclipse.org/alf/schema/EventBase/1" version="1.0">
<xs:element name="Close" type="tns:closeDocument"/>
<xs:element name="Create" type="tns:createDocument"/>
<xs:element name="Reopen" type="tns:reopenDocument"/>
<xs:element name="Update" type="tns:updateDocument"/>
<xs:complexType name="closeDocument">
<xs:sequence>
<xs:element name="ticketid" type="xs:string"/>
<xs:element name="incidentid" type="xs:string"/>
<xs:element name="solutionDescription" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="createDocument">
<xs:sequence>
<xs:element name="ticketid" type="xs:string"/>
<xs:element name="shortDescription" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="updateDocument">
<xs:complexContent>
<xs:extension base="tns:reopenDocument">
<xs:sequence>
<xs:element minOccurs="0" name="workLog" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="reopenDocument">
<xs:sequence>
<xs:element name="ticketid" type="xs:string"/>
<xs:element name="incidentid" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://www.eclipse.org/alf/schema/EventBase/1"
xmlns:tns="http://xxx.de/sbm/incident" attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://xxx.de/sbm/incident">
<xs:import namespace="http://www.eclipse.org/alf/schema/EventBase/1"/>
<xs:element name="closeIncident" type="tns:closeIncident"/>
<xs:element name="closeIncidentResponse" type="tns:closeIncidentResponse"/>
<xs:element name="createIncident" type="tns:createIncident"/>
<xs:element name="createIncidentResponse" type="tns:createIncidentResponse"/>
<xs:element name="reopenIncident" type="tns:reopenIncident"/>
<xs:element name="reopenIncidentResponse" type="tns:reopenIncidentResponse"/>
<xs:element name="updateIncident" type="tns:updateIncident"/>
<xs:element name="updateIncidentResponse" type="tns:updateIncidentResponse"/>
<xs:complexType name="closeIncident">
<xs:sequence>
<xs:element minOccurs="0" name="close" type="ns1:closeDocument"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="closeIncidentResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="createIncident">
<xs:sequence>
<xs:element minOccurs="0" name="create" type="ns1:createDocument"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="createIncidentResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="updateIncident">
<xs:sequence>
<xs:element minOccurs="0" name="update" type="ns1:updateDocument"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="updateIncidentResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="reopenIncident">
<xs:sequence>
<xs:element minOccurs="0" name="reopen" type="ns1:reopenDocument"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="reopenIncidentResponse">
<xs:sequence/>
</xs:complexType>
<xs:element name="ServiceError" type="tns:ServiceError"/>
<xs:complexType name="ServiceError">
<xs:sequence>
<xs:element name="errorMessage" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="closeIncidentResponse">
<wsdl:part name="parameters" element="tns:closeIncidentResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="reopenIncidentResponse">
<wsdl:part name="parameters" element="tns:reopenIncidentResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="ServiceException">
<wsdl:part name="ServiceException" element="tns:ServiceError">
</wsdl:part>
</wsdl:message>
<wsdl:message name="updateIncidentResponse">
<wsdl:part name="parameters" element="tns:updateIncidentResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="updateIncident">
<wsdl:part name="parameters" element="tns:updateIncident">
</wsdl:part>
</wsdl:message>
<wsdl:message name="createIncident">
<wsdl:part name="parameters" element="tns:createIncident">
</wsdl:part>
</wsdl:message>
<wsdl:message name="createIncidentResponse">
<wsdl:part name="parameters" element="tns:createIncidentResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="reopenIncident">
<wsdl:part name="parameters" element="tns:reopenIncident">
</wsdl:part>
</wsdl:message>
<wsdl:message name="closeIncident">
<wsdl:part name="parameters" element="tns:closeIncident">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="IncidentService">
<wsdl:operation name="closeIncident">
<wsdl:input name="closeIncident" message="tns:closeIncident">
</wsdl:input>
<wsdl:output name="closeIncidentResponse" message="tns:closeIncidentResponse">
</wsdl:output>
<wsdl:fault name="ServiceException" message="tns:ServiceException">
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="createIncident">
<wsdl:input name="createIncident" message="tns:createIncident">
</wsdl:input>
<wsdl:output name="createIncidentResponse" message="tns:createIncidentResponse">
</wsdl:output>
<wsdl:fault name="ServiceException" message="tns:ServiceException">
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="updateIncident">
<wsdl:input name="updateIncident" message="tns:updateIncident">
</wsdl:input>
<wsdl:output name="updateIncidentResponse" message="tns:updateIncidentResponse">
</wsdl:output>
<wsdl:fault name="ServiceException" message="tns:ServiceException">
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="reopenIncident">
<wsdl:input name="reopenIncident" message="tns:reopenIncident">
</wsdl:input>
<wsdl:output name="reopenIncidentResponse" message="tns:reopenIncidentResponse">
</wsdl:output>
<wsdl:fault name="ServiceException" message="tns:ServiceException">
</wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="IncidentServiceServiceSoapBinding" type="tns:IncidentService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="closeIncident">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="closeIncident">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="closeIncidentResponse">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ServiceException">
<soap:fault name="ServiceException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="createIncident">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="createIncident">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="createIncidentResponse">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ServiceException">
<soap:fault name="ServiceException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="updateIncident">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="updateIncident">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="updateIncidentResponse">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ServiceException">
<soap:fault name="ServiceException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="reopenIncident">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="reopenIncident">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="reopenIncidentResponse">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ServiceException">
<soap:fault name="ServiceException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="IncidentServiceService">
<wsdl:port name="IncidentServicePort" binding="tns:IncidentServiceServiceSoapBinding">
<soap:address location="http://localhost:9090/IncidentServicePort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Und einmal was die 'trace'-Funktionen "__getFunctions" und "__getTypes()" zurückgeben:
Code:
<?php var_dump($client->__getFunctions());?>
array
0 => string 'closeIncidentResponse closeIncident(closeIncident $parameters)' (length=62)
1 => string 'createIncidentResponse createIncident(createIncident $parameters)' (length=65)
2 => string 'updateIncidentResponse updateIncident(updateIncident $parameters)' (length=65)
3 => string 'reopenIncidentResponse reopenIncident(reopenIncident $parameters)' (length=65)
<?php var_dump($client->__getTypes()); ?>
array
0 => string 'struct closeDocument {
string comnetid;
string incidentid;
string solutionDescription;
}' (length=91)
1 => string 'struct createDocument {
string comnetid;
string shortDescription;
}' (length=69)
2 => string 'struct updateDocument {
string workLog;
}' (length=42)
3 => string 'struct reopenDocument {
string comnetid;
string incidentid;
}' (length=63)
4 => string 'struct closeIncident {
closeDocument close;
}' (length=46)
5 => string 'struct closeIncidentResponse {
}' (length=32)
6 => string 'struct createIncident {
createDocument create;
}' (length=49)
7 => string 'struct createIncidentResponse {
}' (length=33)
8 => string 'struct updateIncident {
updateDocument update;
}' (length=49)
9 => string 'struct updateIncidentResponse {
}' (length=33)
10 => string 'struct reopenIncident {
reopenDocument reopen;
}' (length=49)
11 => string 'struct reopenIncidentResponse {
}' (length=33)
12 => string 'struct ServiceError {
string errorMessage;
}' (length=45)
Ich habe vorher bereits 2 WebServices Firmenintern via PHP angesprochen.
Und zwar den Exchange WebService von unserem Exchange-Server.
Funktioniert alles wunderbar, ein bisschen habe ich also vorher schon mit WebServices unter PHP gemacht,
leider scheint mir das hier nicht weiterzuhelfen.
Zum Schluss habe ich noch etwas was ich nicht ganz verstehe,
normalerweise hätte ich Gedacht mein Script müsse folgendermaßen aufgebaut sein:
PHP-Code:
# Pfad zur .wsdl
$FileForWSDL = realpath('incidentservice.wsdl');
$client;
if($FileForWSDL){
# Verbindung zum WebService erstellen
$client = new SoapClient(
$FileForWSDL,
array('login' => "einLogin",
'password' => "einPasswort",
'location' => "https://yyy.xxx.de/incident-webservice/Event?wsdl=IncidentService.wsdl",
'uri' => "http://xxx.de/sbm/incident",
'trace' => 1
)
);
}else{
die('Destionation-URI for WSDL-File unreachable, try again later or check configuration.');
}
# Übergabewerte für Funktion
$createDocument->ticketid = "123456";
$createDocument->shortDescription = "Test Text";
try
{
# Entweder so:
$result = $client->createIncident("123456", "Test Text");
# oder so:
$result = $client->createIncident($createDocument);
}
catch(Exception $e)
{
echo ' <b>Error:</b> '.$e;
echo '<br/> <b>LastRequest:</b> '.$client->__getLastRequest();
echo '<br/> <b>LastRequestHead:</b> '.$client->__getLastRequestHeaders();
echo '<br/> <b>LastResponse:</b> '.$client->__getLastResponse();
echo '<br/> <b>LastResponseHead:</b> '.$client->__getLastResponseHeaders();
}
# Ausgabe der Rückmeldung
echo "<p>Result:</p>";
echo "<pre>";
@print_r($result);
echo "</pre>";
Es wäre echt super wenn Ihr mir weiterhelfen könntet, mir gehen so langsam die Ideen aus.
Vielen Dank schonmal für die die sich die zeit hierfür nehmen.