HTTPS integration with customer

Hi,

I have a questions related to integration with Integration Server. I am wondering how trading partner can connect and send/receive data using IS and HTTPS as transport protocol. We (as trading partner) don’t have any out-of-box trading partner software to do the connnectivity. Does WM provide client software for trading partners? Maybe there are avaliable any third party solutions for tradning partners? or AS2 compliancy is enought to choose trading partner software.

Thanks for advice

Pawel

Hi Pawel,
I think that you should read webMethods Trading Networks Concepts Guide 6.1.

and about invoking services on IS, you can read in Developer User Guide,
Hope that helps a little bit,
Kasper

Thansk for help, unfortunatly We don’t use wm and we don’t have acces to WM advantage. Is any other way to get the document :frowning:

Hi Pawel,
What I got from your posts that you don’t have WM IS and want to connect to a partner’s WM IS server over HTTPS.

If your requirement is simply that, and you have the JVM installed on your machine, then ask your partner to create the java client code using their WM Developer tool and give it to you. You can compile the code and run it to connect to the Partner’s IS over HTTPS and invoke a service there to exchange the document.

WM provides developer tool to generate the java client code. Using Developer one can also generate client code C, VB or Excel. Also, using a browser you can invoke a WM IS service with a URL or use a HTML FORM or JSP page to invoke the service.

But if your requirement also entailes using AS2 over HTTPS, then you need to look at available software tool (WM IS/TN being 1 of them). AS2 involves exchanging MDN and much more.

HTH,
Bhawesh.

I believe a “partner server” license of webMethods Integration Server is a full-blown IS restricted to the use of a single adapter for a single integration with the “hub” of the trading exchange.

Assuming that this is still correct, your sponsoring trading partner (hub) should provide the software and documentation for your Partner Server installation.

Mark

Dear Bhawesh,

Thansk a lot for help. We will probably try to use HTML form to invoke the service. I knwo that Seebeyond (we are using this software as Middleware) has some solution to do so.

Cheers,

Pawel

Hi Pawel,

Here is a sample java code that you can use to send xml files to your partners server. All you need is a working jvm on your machine and to use a working keystore containing your private key, public key and CA certificate,

The code is
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;

public class WmTNInvoker {

public static void showUsage() {
	System.out
			.println("Usage: java WmTNInvoker <url> <username> <password> [-file <file to send>] [-keystorename <keystorename> -keystorepassword <keystore password>]");
	System.out.println("Keystore name and password needed if you create a HTTPS connection"); 
}

public static void process (URL theUrl, String username, String password, String fileName, String keystoreName, String keystorePassword)
throws IOException
{
	System.out.println (">>> Processing " + theUrl.toExternalForm()); 
	if (fileName != null)
		System.out.println (">>> File : " + fileName); 
	
	if (keystoreName != null)
	{
		System.out.println(">>> Using keystore " + keystoreName); 
	 
		System.setProperty("javax.net.ssl.keyStore", keystoreName); 
		System.setProperty("javax.net.ssl.keyStorePassword", keystorePassword); 
		System.setProperty("javax.net.ssl.trustStore", keystoreName); 
		System.setProperty("javax.net.ssl.trustStorePassword", keystorePassword);
	}
	
	HttpURLConnection conn = (HttpURLConnection) theUrl.openConnection();
	conn.setRequestMethod("POST");
	conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");

            boolean authspec = false;                

            if (username.equals("") && password.equals(""))
               authspec = false; 
            else
               authspec = true; 
         
            if (authspec)
            {
	    String authString = username + ":" + password;
	    String auth = "Basic "
			+ new sun.misc.BASE64Encoder().encode(authString.getBytes());
	    conn.setRequestProperty("Authorization", auth);
            }

	conn.setDoOutput(true);
	conn.setDoInput(true);
	OutputStream os = conn.getOutputStream();

	if (fileName != null) {
		BufferedReader in = new BufferedReader(new FileReader(fileName));
		boolean ready = false;
		String newLine = System.getProperty("line.separator");
		while (!ready) {
			String readString = in.readLine();
			if (readString != null) {
				os.write(readString.getBytes());
				os.write(newLine.getBytes());
			} else
				ready = true;
		}
	}			
	os.close();

	InputStream is = conn.getInputStream();
	InputStreamReader fromWm = new InputStreamReader(is);
	BufferedReader fromWmReader = new BufferedReader(fromWm);
	boolean ready = false;
	while (!ready) {
		String readString = fromWmReader.readLine();
		if (readString != null) {
			System.out.println(readString);
		} else
			ready = true;
	}
	os.close();		
	System.out.println (">>> Processing done"); 
}

/**
 * @throws IOException
 */
public static void main(String[] args) throws IOException {


            HostnameVerifier hv = new HostnameVerifier() {
               public boolean verify(String urlHostName, SSLSession session) {
                  System.out.println("Warning: URL Host: "+urlHostName+" vs. "+session.getPeerHost());
                  return true;
               }
            };

            HttpsURLConnection.setDefaultHostnameVerifier(hv);

	long startTime = System.currentTimeMillis(); 
	URL theUrl = null;
	String username = null;
	String password = null;
	int argCounter = 0; 
	try {
		String urlText = args[argCounter++]; 
		theUrl = new URL(urlText);
		username = args[argCounter++];
		password = args[argCounter++];
	} catch (ArrayIndexOutOfBoundsException e) {
		showUsage();
		return;
	} catch (MalformedURLException mue) {
                    mue.printStackTrace(); 
                    showUsage (); 
                    return; 
            }
					
	String keystoreName = null; 
	String keystorePassword = null;
	String fileName = null;
	
	boolean allArgsParsed = false;
	
	while (!allArgsParsed)
	{
		try
		{
			String switchName = args[argCounter++];
			String value = null; 
                            try
                            {
                                value = args[argCounter++]; 
                            }
                            catch (ArrayIndexOutOfBoundsException e)
                            {
                                showUsage (); 
                                return; 
                            }
			if (!value.startsWith("-"))
			{
				if (switchName.toLowerCase().equals("-file"))
				{
					fileName = value;
				}
				else if (switchName.toLowerCase().equals("-keystorename"))
				{
					keystoreName = value; 
				}
				else if (switchName.toLowerCase().equals("-keystorepassword"))
				{
					keystorePassword = value;  
				}
                                    else
                                    {
                                            showUsage (); 
                                            return; 
                                    }
			}
			else
				argCounter--; 
		}
		catch (ArrayIndexOutOfBoundsException e)
		{
			allArgsParsed = true; 
		}
	}
			
    if ((fileName != null) && (fileName.indexOf("#") != -1))
    {
    	System.out.println ("Multiple files specified"); 
    	boolean ready = false;
    	int counter = 1; 
    	while (!ready)
    	{
    		String thisFileName = fileName;
			thisFileName = thisFileName.replaceAll("#",new Integer(counter).toString()); 	    		
    		File thisFile = new File (thisFileName); 
    		if (thisFile.exists())
    		{
                            try
                            {
                                long processStartTime = System.currentTimeMillis(); 
    			    process (theUrl, username, password, thisFileName, keystoreName, keystorePassword); 
                                long processEndTime = System.currentTimeMillis(); 
                            System.out.println (">>> This document took : " + (processEndTime-processStartTime) + " ms."); 
                            }
                            catch (IOException ioe)
                            {
                                ioe.printStackTrace(); 
                            }
    			counter++;
    		}
    		else
    			ready = true; 
    	}
    }
    else
        {
            try
            {
    	    process (theUrl, username, password, fileName, keystoreName, keystorePassword); 
            }
            catch (IOException ioe)
            {
                ioe.printStackTrace (); 
            }
        }
    long endTime = System.currentTimeMillis(); 
    System.out.println (">>> Execution time : " + (endTime-startTime) + " ms."); 
	
}

}
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’’

You can run the above code using command given below.
For using https

java WmTNInvoker https://host:port/invoke/wm.tn/receive “” “” -file filenameOfTheFile youWantToSend -keystorename yourKeyStore.jks -keystorepassword passwordForYourKeyStore

For Using http
java WmTNInvoker http://host:port/invoke/wm.tn/receive -file filenameOfTheFile youWantToSend

The above code just supports secure post of documents.Does not support AS2.

HTH
Yogesh

Hi Pawel,

My experience with Seebeyond in trying to create/process XML data or use HTML Forms has not been so good. But then, this was in 2001. Hope they have done better job in new versions. Best of luck.

Regards,
Bhawesh.