Hi,
ich würde gern einen in PHP geschriebenen WebService in Java aufrufen.
Komm aber kein bisschen weiter gerade.
Habe schon den SOAP-Client aus dem Buch "JavaEE 5 Einstieg für Anspruchsvolle" probiert, einen Client aus dem Internet (mit apache SOAP, das apache SOAP Projekt findet man aber irgendwie nicht mehr) und mit einem example Client aus dem Axis Projekt.
Mein PHP Code:
WSDL Datei:
Bei dem Axis Example kommt zB die Fehlermeldung
EDIT:
Habs hinbekommen. War im Endeffekt doch gar nicht so schwer. Man muss blos erst mal was brauchbares dazu finden. Client Code sieht jetzt so aus:
ich würde gern einen in PHP geschriebenen WebService in Java aufrufen.
Komm aber kein bisschen weiter gerade.
Habe schon den SOAP-Client aus dem Buch "JavaEE 5 Einstieg für Anspruchsvolle" probiert, einen Client aus dem Internet (mit apache SOAP, das apache SOAP Projekt findet man aber irgendwie nicht mehr) und mit einem example Client aus dem Axis Projekt.
Mein PHP Code:
Code:
<?php
function ctrl($action)
{
return "Action is: ".$action;
}
$server = new SoapServer("controller.wsdl");
$server->addFunction("ctrl");
$server->handle();
?>
WSDL Datei:
Code:
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='Controller'
targetNamespace='http://mySite.de/Controller'
xmlns:tns='http://mySite.de/Controller'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='ctrlRequest'>
<part name='action' type='xsd:string'/>
</message>
<message name='ctrlResponse'>
<part name='Result' type='xsd:string'/>
</message>
<portType name='ctrlPortType'>
<operation name='ctrl'>
<input message='tns:ctrlRequest'/>
<output message='tns:ctrlResponse'/>
</operation>
</portType>
<binding name='ctrlBinding' type='tns:ctrlPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='ctrl'>
<soap:operation soapAction='urn:Controller#ctrl'/>
<input>
<soap:body use='encoded' namespace='urn:Controller'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:Controller'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='ctrlService'>
<port name='ctrlPort' binding='ctrlBinding'>
<soap:address location='mySite.de/controller.php'/>
</port>
</service>
</definitions>
Bei dem Axis Example kommt zB die Fehlermeldung
Code:
Exception in thread "main" java.io.IOException: Emitter failure. There is an undefined binding (ctrlBinding) in the WSDL document.
Hint: make sure <port binding=".."> is fully qualified.
EDIT:
Habs hinbekommen. War im Endeffekt doch gar nicht so schwer. Man muss blos erst mal was brauchbares dazu finden. Client Code sieht jetzt so aus:
Java:
String wsEndpoint = "http://mySite/controller.php";
String wsMethod = "ctrl";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress( new URL( wsEndpoint ) );
call.setOperationName( wsMethod );
call.addParameter( "action", Constants.XSD_STRING, ParameterMode.IN );
call.setReturnType( Constants.XSD_STRING );
Object ret = call.invoke( new Object[] { "TestAction" } );
System.out.println( ret );
Zuletzt bearbeitet: