EDIXMLOnline 

Skip Navigation Links
Home
Account
DemosExpand Demos
SupportExpand Support
Blog/Contact
Login

Using the Web Service with Java (NetBeans 6.x)



The web service client application we will write will cover all the operations of EDIXMLOnline you need to generate and translate an EDI file. This tutorial used a daily build of Sun Netbeans 6 and Java SDK 6 update 3, for Windows.

After installing the Java SDK and Netbeans be sure to copy the jar files under C:\Program Files\NetBeans 6.0 XXX\java1\modules\ext\jaxws21\api to an "Endorsed" folder under the "Lib" folder in both the JRE and SDK folders.


Let's begin.

Save a local copy of the generated WSDL file.



Create a new Java Application project. Call it JavaClientDemo.

Add the JAX-WS 2.1 library.
Add the Swing Application Framework library

Add a web service client using the saved WSDL.





This step of adding a web reference is to generate and include the .NET class that represents the 850 SEF file which is defined by an Xml schema, that is embedded in the WSDL. The proxy functions defined in the WSDL are not to be called as they do nothing.


Add another web service client to the EDIXMLOnline web service.




This step of adding a web reference is to generate and include the proxy class of the actual web service that will generate and translate EDI files.


Your projects pane should be similar to




Add a JFrame form, call it MainForm. Layout controls on the form to make it look like. The SEF ID should be the id created for the SEF file you uploaded and wish to use in your application. And for this example it was one that was created under the "demo" user and happens to be b5c0771a-ace2-436c-bb9e-e8ff98b2b042 .



Add the code to the application main constructor to create and display an instance of the form.




Add a class, call it "DefaultNamespacePrefixMapper". The source file should look like




Let's start adding code to the MainForm. First, add the necessary imports at the top of the class file.



We will add a few private instance variables to the form and initialize a few in the constructor of the form.





The ActionPerformed event for the "Login" button looks like



The ActionPerformed event for the "Generate EDI in code" button looks like



The ActionPerformed event for the "Translate EDI Text (Serialized Xml)" button looks like



The ActionPerformed event for the "Translate EDI File To XML" button looks like



The ActionPerformed event for the "Generate From XML To EDI" button looks like




The ActionPerformed event for the "Validate EDI Text" button looks like




The ActionPerformed event for the "Validate XML Text" button looks like the one for the EDI except that it calls the "ValidateXml" service operation.


Run the application.



Note

You will find that the raw Xml from the Translation service will not validate as well as the Xml created from a serialized proxy object. This is because the serialized xml is more complete and is dictated by the proxy class that was created based on the rules defined in the schema information found in the WSDL. Whereas, the translation service forumlates its xml reply based on the EDI payload and the rules defined by the SEF file.

So, the raw xml file from the translation service is not an accurate representation of EDI payload, you must deserialize it into a proxy object and interrogate the properties of the object.




Register for an account and start programming with the EDIXMLOnline web service. We provide you with a few SEF files in your account for you to use.
Copyright © 2007 Business Integration Inc. All rights reserved. Terms of Use Privacy Policy