package wsif; import javax.wsdl.Definition; import javax.wsdl.Input; import javax.wsdl.Operation; import javax.wsdl.Output; import javax.wsdl.PortType; import org.apache.wsif.WSIFMessage; import org.apache.wsif.WSIFOperation; import org.apache.wsif.WSIFPort; import org.apache.wsif.WSIFService; import org.apache.wsif.WSIFServiceFactory; import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis; import org.apache.wsif.util.WSIFPluggableProviders; import org.apache.wsif.util.WSIFUtils; public class WSIFInvoke { private Definition def = null; public static void main(String[] args){ String wsdlLoc1 = "http://localhost:8080/WSIFDemo/services/Hello?wsdl"; // String opName = "sayHello"; String value = "Wilson"; String opName = "sayHi"; WSIFInvoke app = new WSIFInvoke(); try { app.run(wsdlLoc1, opName, value); } catch (Exception e) { e.printStackTrace(); } } public void run(String wsdlLoc, String opName, String value) throws Exception { def = WSIFUtils.readWSDL(null, wsdlLoc); WSIFPluggableProviders.overrideDefaultProvider("http://schemas.xmlsoap.org/wsdl/soap/",new WSIFDynamicProvider_ApacheAxis()); WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); WSIFService dpf = factory.getService(def); WSIFPort port = dpf.getPort(); PortType portType = WSIFUtils.selectPortType(def, null, null); Operation op = portType.getOperation( opName, opName + "Request", opName + "Response"); Input opInput = op.getInput(); Output opOutput = op.getOutput(); String inputName = opInput.getName(); String outputName = opOutput.getName(); WSIFOperation operation = port.createOperation(opName, inputName,outputName); WSIFMessage input = operation.createInputMessage(); WSIFMessage output = operation.createOutputMessage(); WSIFMessage fault = operation.createFaultMessage(); input.setObjectPart("name", value); String result = ""; if (operation.executeRequestResponseOperation(input, output, fault)) { result = (String) output.getObjectPart(opName + "Return"); } else { System.out.println("not working"); } System.err.println(result); } }