php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger

PHP Einsteiger PHP Problemlösungen für Spracheinsteiger
Archive: 2004, 2004/2, 2005, 2005/2, 2006, 2007, 2008, 2009, 2010,

Antwort
 
LinkBack Themen-Optionen Thema bewerten
Alt 19.01.2012, 11:11  
Neuer Benutzer
 
Registriert seit: 25.10.2011
Beiträge: 7
PHP-Kenntnisse:
Anfänger
Nofoxx befindet sich auf einem aufstrebenden Ast
Standard Ansprechen eines WebService

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.
Nofoxx ist offline   Mit Zitat antworten
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 25.01.2012, 14:52  
Neuer Benutzer
 
Registriert seit: 25.10.2011
Beiträge: 7
PHP-Kenntnisse:
Anfänger
Nofoxx befindet sich auf einem aufstrebenden Ast
Standard

Gibt es wirklich niemanden der vielleicht eine Idee hat?
Ich bin leider selber noch kein Stück weiter gekommen :\
Nofoxx ist offline   Mit Zitat antworten
Antwort


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
[Erledigt] Mit Prototype Select Element ansprechen eisenhans JavaScript, Ajax und mehr 6 10.11.2011 17:48
JOOMLA | PHP - MYSQl Spalten ansprechen DonDemf PHP Einsteiger 3 12.09.2011 12:40
Aufruf Webservice funktioniert nicht vsnase PHP Einsteiger 5 21.06.2011 10:55
Tabellenfelder ansprechen Choba PHP Tipps 2010 21 24.11.2010 20:42
Freelancer für PHP Webservice Kommunikation gesucht inst0000 Beitragsarchiv 0 18.06.2009 16:34
Webservice ansprechen WSDL NuSOAP Curl webdino PHP Tipps 2009 0 08.04.2009 10:56
PHP Soap Webservice aufrufen Zender JavaScript, Ajax und mehr 4 11.10.2008 20:08
Dateiupload via Webservice vsnase PHP Tipps 2008 2 13.08.2008 05:05
Formular in Hauptfenster auf iframe ansprechen R.E.M. HTML, Usability und Barrierefreiheit 2 24.09.2006 15:33
Unsichtbares Formularfeld mit Javascript ansprechen mAy^daY HTML, Usability und Barrierefreiheit 6 13.08.2006 21:25
Seite per ID ansprechen? tayke PHP Tipps 2006 4 01.06.2006 23:37
[Erledigt] XML Daten an Webservice senden PHP-Fortgeschrittene 0 25.05.2006 21:11
WebService über NUSOAP gibt NULL (leeres result) zurück andre_shd PHP-Fortgeschrittene 4 16.05.2006 14:12
[Erledigt] Asynchroner Webservice mit NUSOAP PHP-Fortgeschrittene 1 22.01.2006 13:18
[Erledigt] Ein Webservice PHP-Fortgeschrittene 10 13.09.2005 07:25

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
soap schnittstelle per nusoap ansprechen, soap schnittstelle mit nusoap ansprechen, wsdl service ansprechen, php verbindung zu web service, webservice ansprechen php, php script exchange server ansprechen, php webservice soap ansprechen

Alle Zeitangaben in WEZ +2. Es ist jetzt 18:59 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum