import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
public class WMClientInvoke {
private static String qnameService = "bhangunWSDL_bhangunService";
private static String qnamePort = "bhangunWSDL_bhangunPortType";
private static String endpoint ="http://localhost:5555/soap/rpc";
private static String BODY_NAMESPACE_VALUE ="bhangunWSDL.bhangun";
private static String ENCODING_STYLE_PROPERTY =
"javax.xml.rpc.encodingstyle.namespace.uri";
private static String URI_ENCODING =
"http://schemas.xmlsoap.org/soap/encoding/";
public static void main(String[] args) {
try {
ServiceFactory factory =
ServiceFactory.newInstance();
Service service =
factory.createService(new QName(qnameService));
QName port = new QName(qnamePort);
Call call = service.createCall(port);
call.setTargetEndpointAddress(endpoint);
call.setProperty(Call.USERNAME_PROPERTY,"myusername");
call.setProperty(Call.PASSWORD_PROPERTY,"mypassword");
call.setProperty(Call.SOAPACTION_USE_PROPERTY,
new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
call.setProperty(ENCODING_STYLE_PROPERTY,
URI_ENCODING);
call.setOperationName(new QName(BODY_NAMESPACE_VALUE,
"panggilNama"));
call.addParameter("nama", new QName(
"http://www.w3.org/2001/XMLSchema", "string"),
String.class, javax.xml.rpc.ParameterMode.IN);
call.setReturnType(new QName(
"http://www.w3.org/2001/XMLSchema", "string"));
String[] params = { "bhangun" };
String result = (String)call.invoke(params);
System.out.println(result);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}