IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Invoking a webMethods flow service from a Weblogic app

  • 1.  Invoking a webMethods flow service from a Weblogic app

    Posted Tue December 07, 2004 11:58 PM

    We have a weblogic application that reads a file as a byte array. This byte array needs to be passed on to a service on webMethods, that will need to send out an email with an attachment that will contain a file created from the contents of the byte array.

    I understand that a service on webMethods may be called from another application using http invoke, and parameters may be passed, but I don’t know if the entire contents of the file could be passed as byte array just like string variables. Once I receive the byte array into a webMethods service… I would be on my way. Guys… any help on this is appreciated.

    Thanks, Rohit


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 2.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Wed December 08, 2004 01:58 AM

    Hello,
    I think that when you receive over http, you will infact get a stream. So your invoked service would need to the wmPublic streamToBytes service. From there you have the rest.

    Good day.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 3.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Fri December 10, 2004 01:50 AM

    Yemi - thanks for the response… but I think I didn’t make myself clear. Let me simplify things. All I need to know is how to invoke a webMethods service from a (say) servlet and pass a byte array.

    If I were to pass a string variable say ‘message’, to a webMethods service named ‘writeMessage’ in a folder ‘service’, I would invoke this service as follows:

    http://<server>:<port>/invoke/service/writeMessage?message=TEST

    But how do I pass on an entire file as byte array…?

    Anyone… plz help! Thanks,
    Rohit


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Wed December 15, 2004 06:46 PM

    Do an HTTP post using normal Java HTTP constructs. Simplified example below:

    [highlight=java]

    // Open an http connection
    URL url = new URL(“http://:/invoke/folder/service”);
    URLConnection connection = url.openConnection();
    HttpURLConnection httpConn = (HttpURLConnection) connection;

    // Set the appropriate HTTP parameters. Change to whatever you need.
    httpConn.setRequestProperty(“Content-Type”,“text/plain; charset=utf-8”);
    httpConn.setDoOutput(true);
    httpConn.setDoInput(true);
    httpConn.setRequestMethod( “POST” );

    // Post the bytes from the file.
    OutputStream out = httpConn.getOutputStream() ;
    out.write(yourBytesHere_OrReadFromYourFileInputStream);
    out.close() ;

    // Read the response.
    InputStreamReader isr = new InputStreamReader(httpConn.getInputStream());
    // Read isr and do whatever you need with it

    [/highlight] Your service will be invoked with a stream or a node or a string or something in the pipeline, depending on the content-type you set.

    HTH.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 5.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Tue January 31, 2006 08:29 PM

    Hi Everyone,

    Is it possible to catch error from the service, which is called using http ?

    Regards,
    Pauly


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 6.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Thu February 02, 2006 03:45 AM

    Hi
    U can use the setResponse service , so that the response for that error will be displayed in the browser when the url is being called.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Thu February 02, 2006 08:49 AM

    Hi,

    I dont know if this will be a better alternative in your case.
    But there is one more way to call wm service. You can create a java client to call wm service from a standalone java application.

    regards,
    Sumit


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 8.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Wed March 22, 2006 06:40 PM

    Hi,

    I’ve find a message where you describe how to send data in a stream to a webMethods service.

    I’ve a problem because when i used this method to invoke wm.tn:receive there is no problem I can find my document in the database but when i want to invoke a personnal service my pipeline is empty even if my first service is streamToByte.
    Could you help me?


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 9.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Wed March 22, 2006 06:59 PM

    To see what data is being passed into your service comment out all other Flow steps and insert a pub.flow:tracePipeline invoke. The output will be written to your IS server log or console. Remember that the variable placed into the pipeline will vary depending on the content-type that you specify in your post.

    Mark


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 10.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Wed March 22, 2006 07:21 PM

    I’ve used your service and i can see this in the server.log

    [10388]2006-03-22 19:35:24 WET [ISP.0090.0002C] — END tracePipeline — swapRows(); writeTDnowrap(“row-l”);
    [10387]2006-03-22 19:35:24 WET [ISP.0090.0008C] 0 node {com.wm.lang.xml.Document} = ‘DOCUMENT System ID: null Public ID: null’ swapRows(); writeTDnowrap(“row-l”);
    [10386]2006-03-22 19:35:24 WET [ISP.0090.0001C] — START tracePipeline [3/22/06 7:35 PM] —

    So there is something in my pipeline named ‘node’ but i don’t know how to use it.

    For information to invoke my service i used a java program:
    [highlight=java]

    conn=(HttpURLConnection)mURL.openConnection();
    conn.setRequestMethod(“POST”);
    conn.setDoOutput(true);
    conn.setDoInput(true);
    conn.setUseCaches(false);
    conn.setRequestProperty(“Cache-Control”, “no-cache”);
    conn.setRequestProperty(“Accept”,“text/xml”);
    conn.setRequestProperty(“Content-Encoding”,“UTF-8”);
    conn.setRequestProperty(“Content-Type”,“text/xml”);
    conn.setRequestProperty(“Content-Length”,“”+((contratStream)?contratFile.length():contrat.length()));
    conn.connect();
    OutputStreamWriter out = new
    OutputStreamWriter(conn.getOutputStream(),“UTF-8”);
    if (! contratStream)
    {
    out.write(contrat,0,contrat.length());
    out.write(“\r\n”,0,2);
    }else
    {
    try {
    BufferedReader in = // new BufferedReader(new
    FileReader(contratFile));
    new BufferedReader(
    new InputStreamReader(
    new FileInputStream(contratFile)
    ,“UTF-8”
    )
    );
    int c ;
    String str;
    while ((str = in.readLine()) != null)
    {
    out.write(str,0,str.length());
    out.write(“\r\n”,0,2);
    }
    in.close();
    }catch (IOException e){e.printStackTrace();}
    }
    out.flush();
    out.close();
    System.out.print("reponse du serveur : ");
    System.out.println(idContrat + " : " +
    conn.getResponseMessage());
    conn.disconnect();

    [/highlight]
    Regards,


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 11.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Wed March 22, 2006 07:36 PM

    Tres,

    The node object that you see is actually an xml node. You should start by defining the input to your service - an object named ‘node’. Map this node object to the input[node] of the pub.xml:xmlNodeToDocument to get an IS document… and you can proceed from there.

    HTH, Rohit


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 12.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Wed March 22, 2006 07:42 PM

    I’m stupid, it was too easy!

    But i don’t know why i used “savePipelinetoFile”, i didn’t see anything in it. I didn’t see an objet maed node.

    Thank’s.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 13.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Wed March 22, 2006 08:04 PM


  • 14.  RE: Invoking a webMethods flow service from a Weblogic app

    Posted Wed March 22, 2006 10:41 PM

    When you pass an XML document to an IS service over HTTP and the content type is text/xml, IS will automatically parse the XML and create an XML node. This is the equivalent of the receiving service performing these steps, if it received the bytes directly:

    bytesToString - given the byte array, converts to a string
    xmlStringToXMLNode - given an XML string, parses to an XML node

    Thus, IS does this work automatically for you. The resulting node is what you want to work with.

    The node can be passed to any number of services, usually xmlNodeToDocument, to perform further processing.

    Of course all of this is in the wM documentation.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods