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
  • 1.  How JAVA application can interact with wM?

    Posted Fri July 10, 2009 08:17 AM

    Hi,

    How can JAVA application can interact with wM (how can they call our service directly? apart from calling our webServices).

    Do wM application team needs to send any of their jar files to Java application team?

    Thanks in advance,
    Sam


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


  • 2.  RE: How JAVA application can interact with wM?

    Posted Fri July 10, 2009 08:31 AM

    Using http you can call a wm service directly.
    Use http://servername:port/invoke/Service_FullyQualifiedName

    You can also exchange data using FTP.

    Cheers
    Guna
    http://www.nibodo.com


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


  • 3.  RE: How JAVA application can interact with wM?

    Posted Fri July 10, 2009 10:31 AM

    You can call the service directly using code like this from a java program:

    
    Context context = new Context();
    IData input= IDataFactory.create();
    IDataCursor idc = input.getCursor();
    idc.insertAfter("myVariable", "Hello!");
    idc.destroy();
    context.connect("distantHost", "login", "password");
    IData output = context.invoke("folderName", "serviceName", input);
    
    //manage output

    you just have to send your application team the client.jar which contains the right classes (IData etc.)


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


  • 4.  RE: How JAVA application can interact with wM?

    Posted Fri July 10, 2009 12:09 PM

    And may I suggest some documents on how to use services and messaging instead of RPC based calls. :smiley: Both of which are very easy to do from Java.


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


  • 5.  RE: How JAVA application can interact with wM?

    Posted Mon July 13, 2009 07:33 AM

    Hi,

    Using Developer got the java client code as below

    /*

    • This class has been automatically generated by the webMethods Developer™.

    /
    import java.io.
    ;
    import java.util.Vector;
    import com.wm.util.Table;
    import com.wm.data.;
    import com.wm.util.coder.IDataCodable;
    import com.wm.app.b2b.util.GenUtil;
    import com.wm.app.b2b.client.Context;
    import com.wm.app.b2b.client.ServiceException;
    public class temp1{
    public static void main(String[] args)
    {
    // Connect to server - edit for alternate server
    String server = “XXXXXXXXXX:5555”;
    Context context = new Context();
    // To use SSL:
    //
    // context.setSecure(true);
    // Optionally send authentication certificates
    //
    // String cert = “c:\myCerts\cert.der”;
    // String privKey = “c:\myCerts\privkey.der”;
    // String cacert = “c:\myCerts\cacert.der”;
    // context.setSSLCertificates(cert, privKey, cacert);
    // Set username and password for protected services
    String username = “Administrator”;
    String password = “manage”;
    try {
    context.connect(server, username, password);
    } catch (ServiceException e) {
    System.out.println(“\n\tCannot connect to server "”+server+“"”);
    System.exit(0);
    }
    try
    {
    // Collect inputs (top-level only)
    IData inputDocument = getInputs();
    // *** Invoke the Service and Disconnect ***
    IData outputDocument = invoke(context, inputDocument);
    context.disconnect();
    System.out.println("\n
    ******** Successful invoke “);
    // *** Access the Results ***
    System.out.println(”\n
    *** Inputs ****“);
    GenUtil.printRec(inputDocument, “Input”);
    System.out.println(”\n
    Outputs *****************");
    GenUtil.printRec(outputDocument, “Output”);
    } catch (IOException e) {
    System.err.println(e);
    } catch (ServiceException e) {
    System.err.println(e);
    }
    System.exit(0);
    }

    // *** Collect Inputs *** //
    public static IData getInputs()
    throws IOException, ServiceException
    {
    return Input_getInputs();
    }
    
    public static IData Output_getInputs()
    throws IOException, ServiceException
    {
    IData out = IDataFactory.create();
    IDataCursor idc = out.getCursor();
    idc.insertAfter("str", getString("str"));
    idc.destroy();
    return out;
    }
    public static IData Input_getInputs()
    throws IOException, ServiceException
    {
    IData out = IDataFactory.create();
    IDataCursor idc = out.getCursor();
    idc.insertAfter("var1", getString("var1"));
    idc.insertAfter("var2", getString("var2"));
    idc.destroy();
    return out;
    }
    public static String getString(String name)
    throws IOException, ServiceException
    {
    System.out.print(name + " =");
    return (new BufferedReader(new InputStreamReader(System.in))).readLine();
    }
    public static String[] getStringArray(String name)
    throws IOException, ServiceException
    {
    int size;
    String tmp;
    System.out.print(name + ": how large? ");
    tmp = (new BufferedReader(new InputStreamReader(System.in))).readLine();
    size = Integer.parseInt(tmp);
    String[] strArray = new String[size];
    for(int i = 0; i < size; i++){
    strArray[i] = getString(name +"[" + i + "]");
    }
    return strArray;
    }
    public static String[][] getStringTable(String name)
    throws IOException, ServiceException
    {
    int rows = 0, cols = 0;
    String tmp;
    System.out.print(name + ": how many rows? ");
    tmp = (new BufferedReader(new InputStreamReader(System.in))).readLine();
    rows = Integer.parseInt(tmp);
    System.out.print(name + ": how many cols? ");
    tmp = (new BufferedReader(new InputStreamReader(System.in))).readLine();
    cols = Integer.parseInt(tmp);
    String[][] strTable = new String[rows][cols];
    for(int i = 0; i < rows; i++){
    for(int j = 0; j < cols; j++){
    strTable[i][j] = getString(name+"["+i+"]["+j+"]");
    }
    }
    return strTable;
    }
    public static IData invoke(
    Context context, IData inputDocument)
    throws IOException, ServiceException
    {
    IData out = context.invoke("Temp", "temp1", inputDocument);
    IData outputDocument = out;
    return outputDocument;
    }
    

    }

    Also compiled successfully, but when I tried to execute from comand prompt, throwing error as below

    c:>java temp1
    Exception in thread “main” java.lang.NoClassDefFoundError: javax/mail/internet/ParseException
    at com.wm.util.Base64.encode(Base64.java:68)
    at com.wm.app.b2b.client.BaseContext.setAuthentication(BaseContext.java:587)
    at com.wm.app.b2b.client.Context.connect(Context.java:527)
    at sample1.main(sample1.java:38)
    Caused by: java.lang.ClassNotFoundException: javax.mail.internet.ParseException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    … 4 more

    Verified the CLASSPATH & PATH

    CLASSPATH=.;C:\jdk1.5.0_19\jre;C:\webMethods7\common\lib;C:\webMethods7\common\lib\ext;

    PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\jdk1.5.0_19;C:\jdk1.5.0_19\bin;C:\jdk1.5.0_19\lib;C:\webMethods7\common\lib;C:\webMethods7\common\lib\ext;
    Am seeing “ws-isclient.jar” file not “client.jar” file (do we have any other client jar file to be included?)
    Any correction please.

    Regards,
    Sam


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


  • 6.  RE: How JAVA application can interact with wM?

    Posted Mon July 13, 2009 08:46 AM

    Hi All,

    It worked now when tried as below from command prompt

    C:>java -classpath .;C:\webMethods7\common\lib\ext\mail.jar;C:\webMethods7\common\lib\wm-isclient.jar temp1

    But don’t know the reason why it didn’t work earlier(because I have set classpath the same as typed in command prompt, CLASSPATH=.;C:\jdk1.5.0_19\jre;C:\webMethods7\common\lib;C:\webMethods7\common\lib\ext;
    )

    Thank you all.
    Sam.


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


  • 7.  RE: How JAVA application can interact with wM?

    Posted Mon July 13, 2009 04:25 PM

    As per the other thread on this topic, IMO, this is not the way to go. Using the IS Java API ties the Java app to IS and isn’t any simpler than using XML over HTTP (you’ll find many more developers know how to do that than use the IS Java API).

    The first attempt didn’t work because the jar file wasn’t on the classpath. When class files are in a jar/zip, that jar/zip must be explicitly on the classpath. Having the directory in which it is located is not sufficient.


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


  • 8.  RE: How JAVA application can interact with wM?

    Posted Tue July 14, 2009 05:51 AM

    Hi Rob,

    Thanks for your information.

    Regards,
    Sam.


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