Invoking Web Services using Java Client

Hello All,
I am new to WebMethods and wanted some help.
We will be getting Web Services and will be deployed in our IS env.
With-in our Java/J2EE application we are suppose to invloke those available Web Services.
Is there any working examples available or can anybody give some tips how to go about it.?

Thanks in advance for your help.

Sanjiv

Sanjiv,
Where will you be invoking the web service from? Are you using a webSphere environment, BEA, Sun, Jboss, plain old java (Using maybe Axis), Eclipse 3.1 with the new WTP web tools? Most of these platforms have wizards to walk you through importing a WSDL that you will need to provide and then generating the stub classes needed to invoke the web service.

They all support different interpretations of the basic web services standards so your mileage will vary depending on the platform. If you give us the specific platform you are using we might be able to provide more information.

Hi ,
Thanks for your reply.We will be getting WSDL file from the 3rd party.
we need to invoke webService that are deployed in IS from BEA J2EE environment via HTTP / SOAP.
Will this information is any help to provide me some direction / tips?

Thanks and Regards
Sanjiv.

Is the third party that is providing the WSDL also creating the Integration Server services that will be exposed as web services? Is your primary responsibility to create the Java application that will use those services and it just so happens that those services will be hosted on an Integration Server? If so, your question may be more appropriate for a forum focused on the toolset you plan to use.

If your plan is to also build the Integration Server services and expose them as web services according the specifications in the third party provided WSDL, then you’ll want to dig deeply into the webMethods-supplied documentation, particularly the “Web Services Developer’s Guide.”

Once you have the WSDL,in the developer create webServiceConnector referencing the wsdl,it will create stubs,documenttypes, webserviceconnector (flowservices) with input/ouput singnatures etc…
Then incorporate the flowservice logic and invoke the hosted webservice via SOAP-HTTP protocol on BEA server as a webservice consumer providing with appropriate requestinputs/responseoutputs from IS.

Please see the Web Services Developer’s Guide and SOAP Developers Guide for implementing webservices in IS.

Hope someone will chim in detailed IS webservice invocation.

HTH,
RMG

RMG, I think you may have missed which direction the WS call will be. You’ve described how to invoke a WS that is hosted on BEA WLS from IS. Sanjiv is asking about invoking as WS that is hosted on IS from BEA WLS. In this case, the web service connector wizard is the wrong thing to do.

Sanjiv,

There are many ways to invoke an IS Flow or java service from a J2EE app server like BEA Weblogic including:

  • use the IS java API to connect to IS and invoke the service
  • publish a JMS message to a queue that is being monitored by an IS JMS adapter polling notification
  • use JAXM and JAX-RPC to invoke an IS service that has been exposed as a soap-rpc or soap-msg (document/literal web service)

Weblogic provides several web services examples to show how to expose web services hosted in Weblogic and to consume web services hosted elsewhere. You can find information on these example on BEA’s DEV2DEV site at this address: https://web-service.projects.dev2dev.bea.com/.

The portions of the example that do the work are:
[highlight=java]
// Setup the global JAXM message factory
System.setProperty(“javax.xml.soap.MessageFactory”,
“weblogic.webservice.core.soap.MessageFactoryImpl”);
// Setup the global JAX-RPC service factory
System.setProperty( “javax.xml.rpc.ServiceFactory”,
“weblogic.webservice.core.rpc.ServiceFactoryImpl”);

// create service factory
ServiceFactory factory = ServiceFactory.newInstance();

// define qnames
String targetNamespace = 
  "http://www.themindelectric.com/" 
  + "wsdl/net.xmethods.services.stockquote.StockQuote/";

QName serviceName = 
  new QName(targetNamespace, 
            "net.xmethods.services.stockquote.StockQuoteService");

QName portName = 
  new QName(targetNamespace, 
            "net.xmethods.services.stockquote.StockQuotePort");

QName operationName = new QName("urn:xmethods-delayed-quotes", 
                                "getQuote");

URL wsdlLocation = 
  new URL("http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl");

// create service
Service service = factory.createService(wsdlLocation, serviceName);

// create call
Call call = service.createCall(portName, operationName);

// invoke the remote web service
Float result = (Float) call.invoke(new Object[] {
  "BEAS"
});

[/highlight]

Hope that helps,

Mark