Call a web service (generated with BEA ServiceGen)Tag(s): Networking
ServiceGen is an utility to generate a client module to access a web service hosted by BEA WLS.
This example use a generated client to call the function list of a Web Service.
import com.company.webservices.client.Commonwebservices; import com.company.webservices.client.CommonwebservicesPort; import com.company.webservices.client.Commonwebservices_Impl; public class Test { public static void main(String ... args) throws Exception{ System.setProperty("weblogic.webservice.verbose", "true"); String wsdlUri = "http://server.company.local/wsdl/commonWS.xml"; Commonwebservices ws = new Commonwebservices_Impl(wsdlUri); CommonwebservicesPort wsp = ws.getcommonwebservicesPort("myusername", "mypassword"); String list = wsc.list(); System.out.println(list); } }
URL : http://server.company.local:80/commonWS/commonwebservices Headers : Content-Length: [459] SOAPAction: [""] Content-Type: [text/xml; charset=utf-8] <?xml version="1.0" encoding="utf-8" standalone="yes"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <env:Header></env:Header> <env:Body env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <m:list xmlns:m="http://company.local/common"></m:list> </env:Body></env:Envelope> <!-------------------- END REQUEST FROM CLIENT ------------> <!-------------------- RESPONSE TO CLIENT ---------------> URL : http://server.company.local:80/commonWS/commonwebservices Response Code :200 Headers : Date=Mon, 17 Aug 2009 14:36:29 GMT Server=Microsoft-IIS/6.0 X-Powered-By=Servlet/2.5 JSP/2.1 Cache-Control=no-cache="set-cookie" Content-Length=1211 Content-Type=text/xml; charset=ISO-8859-1 Set-Cookie=JSESSIONID=BJYXKJqfFC7nl9TMgYkJg9DpL5kZ1nTQy2M8v1BXJnT1R8n1DhfX!-1553076658; path=/ Envelope : <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <env:Header></env:Header> <env:Body env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <m:listResponse xmlns:m="http://company.local/common"> <result xsi:type="xsd:string">\\company.local\fonc_sas, \\company.local\unit_sas, \\company.local\prod_sas </result></m:listResponse></env:Body></env:Envelope> <!-------------------- END RESPONSE TO CLIENT -----------> \\company.local\fonc_sas, \\company.local\unit_sas, \\company.local\prod_sas
String wsdlUri = "http://myusername:mypassword@server.company.local/commonWS/commonwebservices?WSDL";
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com