Invoking a webMethods flow service from a Weblogic app

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

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.

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:


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

Anyone… plz help! Thanks,

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


// 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.setRequestMethod( “POST” );

// Post the bytes from the file.
OutputStream out = httpConn.getOutputStream() ;
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.


Hi Everyone,

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


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.


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.



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 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?

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.


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:

conn.setRequestProperty(“Cache-Control”, “no-cache”);
OutputStreamWriter out = new
if (! contratStream)
try {
BufferedReader in = // new BufferedReader(new
new BufferedReader(
new InputStreamReader(
new FileInputStream(contratFile)
int c ;
String str;
while ((str = in.readLine()) != null)
}catch (IOException e){e.printStackTrace();}
System.out.print("reponse du serveur : ");
System.out.println(idContrat + " : " +



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

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.


Im glad you got it work :slight_smile:

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.