Thomas Darimont
Erfahrenes Mitglied
Hallo,
so kannst du dir aus einem WSDL Dokument einen Client generieren lassen (Beispiel unter Java 6):
Ergebnis in generated:
Gruß Tom
so kannst du dir aus einem WSDL Dokument einen Client generieren lassen (Beispiel unter Java 6):
Code:
D:\tmp\ws>mkdir generated
D:\tmp\ws>mkdir source
D:\tmp\ws>wsimport -d generated -s source http://localhost:44444/Calculator?wsdl
Ergebnis in generated:
Java:
package de.tutorials;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
/**
* This class was generated by the JAXWS SI.
* JAX-WS RI 2.0_02-b08-fcs
* Generated source version: 2.0
*
*/
@WebService(name = "ICalculator", targetNamespace = "http://tutorials.de/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface ICalculator {
/**
*
* @param arg1
* @param arg0
* @return
* returns int
*/
@WebMethod
@WebResult(partName = "return")
public int computeSumOf(
@WebParam(name = "arg0", partName = "arg0")
int arg0,
@WebParam(name = "arg1", partName = "arg1")
int arg1);
}
Java:
package de.tutorials;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
/**
* This class was generated by the JAXWS SI.
* JAX-WS RI 2.0_02-b08-fcs
* Generated source version: 2.0
*
*/
@WebServiceClient(name = "Calculator", targetNamespace = "http://tutorials.de/", wsdlLocation = "http://localhost:44444/Calculator?wsdl")
public class Calculator
extends Service
{
private final static URL CALCULATOR_WSDL_LOCATION;
static {
URL url = null;
try {
url = new URL("http://localhost:44444/Calculator?wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
}
CALCULATOR_WSDL_LOCATION = url;
}
public Calculator(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public Calculator() {
super(CALCULATOR_WSDL_LOCATION, new QName("http://tutorials.de/", "Calculator"));
}
/**
*
* @return
* returns ICalculator
*/
@WebEndpoint(name = "Calculator")
public ICalculator getCalculator() {
return (ICalculator)super.getPort(new QName("http://tutorials.de/", "Calculator"), ICalculator.class);
}
}
Gruß Tom