php to java webservice
SOAP connection to Java Web Service from PHP
Source: http://coding.derkeiler.com/Archive/PHP/alt.php/2006−09/msg00127.html
· From: tayze@xxxxxxxxx
· Date: 9 Sep 2006 08:43:35 −0700
I've been struggling with this for a while and am finally resorting to
asking for help.
Below is the code that works in java:
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
import java.net.URL;
import java.util.Vector;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.SOAPException;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;
import java.io.*;
import java.util.*;
public class TopXCall {
public static void main(String argv[]) {
try {
String endpoint =
"http://infao5501.ag5.mpi−sb.mpg.de:8080/soap/servlet/rpcrouter;
// Initialize the method parameters
Vector params = new Vector();
// Create the call.
Call call = new Call();
call.setTargetObjectURI("TopXService");
call.setMethodName("processQuery");
call.setParams(params);
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
// Invoke the call.
Response response = null;
SOAP connection to Java Web Service from PHP
SOAP connection to Java Web Service from PHP 1page
try {
response = call.invoke(new URL(endpoint), "");
if (response.generatedFault()) {
Fault fault = response.getFault();
System.err.println("Generated fault: " + fault);
} else {
System.out.println(response.getReturnValue().getValue());
}
} catch (SOAPException e) {
System.err.println("Caught SOAPException (" +
e.getFaultCode() + "): " + e.getMessage());
}
}
catch(Exception e) {
System.err.println("Exception caught: " + e.getMessage());
}
}
}
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Now I'm trying to get it to work in PHP. I believe I need to create a
WSDL file since there was not one provided.
Below is my PHP code and attempt at a WSDL file. I coppied a sample
file and modified the parts to suit my needs ... obviously I have made
some errors.
Any help or advice would be greatly appreciated.
Tayze
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
require_once('nusoap.php');
$wsdl="http://www.myserver.com/soap/TopXService.wsdl;
$client=new soapclient($wsdl, 'wsdl');
$param=array(
'query'=>'//article[about(., java)]',
'collectionIndex'=>0,
'mode'=>0,
'k'=>10,
'page'=>0,
'conjunctive'=>false
SOAP connection to Java Web Service from PHP
SOAP connection to Java Web Service from PHP 2page
);
echo $client−>call('processQuery', $param);
echo 'Request: '.$client−>request.' ';
echo 'Response: '.$client−>response.' ';
echo 'Debug log:
'.$client−>debug_str.'';?>
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
targetNamespace="http://www.tayze.com/soap/TopXService.wsdl
xmlns:tns="http://www.tayze.com/soap/TopXService.wsdl
xmlns:xsd="http://www.w3.org/2001/XMLSchema
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/
xmlns="http://schemas.xmlsoap.org/wsdl/>
transport="http://schemas.xmlsoap.org/soap/http"/>
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
SOAP connection to Java Web Service from PHP
SOAP connection to Java Web Service from PHP 3page
location="http://infao5501.ag5.mpi−sb.mpg.de:8080/soap/servlet/rpcrouter"/>
.
SOAP connection to Java Web Service from PHP
SOAP connection to Java Web Service from PHP 4page
Comments