After creating the proxy objects (class) by importing your WSDL file, you can start
writing code against the class. Following are code snippets that give an idea on
how to use the proxy objects and the EDIXMLOnline web service. For more complete
code view the
tutorials.
Using the generated classes
// Create EDI document type from proxy class generated from WSDL
SEF850.EdiDocument ediDoc =
new WebServiceDemoClient.SEF850.EdiDocument();
// Define Interchange Header
ediDoc.InterchangeControlHeader
= new InterchangeControlHeaderISA();
ediDoc.InterchangeControlHeader.AuthorizationInformationQualifier
= "00";
ediDoc.InterchangeControlHeader.AuthorizationInformation
= " ";
ediDoc.InterchangeControlHeader.SecurityInformationQualifier = "00";
ediDoc.InterchangeControlHeader.SecurityInformation
= " ";
.
.
.
// Define Functional Group
ediDoc.FunctionalGroupHeader
= new FunctionalGroupHeaderGS();
ediDoc.FunctionalGroupHeader.FunctionalIdentifierCode =
"PO";
ediDoc.FunctionalGroupHeader.ApplicationSendersCode
= "SENDERGS";
.
.
.
// Define 1st "Purchase Order" transactionset
ediDoc.TransactionSets
= new PurchaseOrder[1];
ediDoc.TransactionSets[0]
= new PurchaseOrder();
ediDoc.TransactionSets[0].TransactionSetHeader
= new TransactionSetHeaderST();
ediDoc.TransactionSets[0].TransactionSetHeader.TransactionSetIdentifierCode
= "850";
ediDoc.TransactionSets[0].TransactionSetHeader.TransactionSetControlNumber = "000000001";
.
.
.
Generating an EDI file is done in a few simple stages
.
.
.
// 1) Serialize edidocument object
to Xml file (or memory stream).
.
.
.
// 2) convert the file (or memory stream) to a byte array
byte[] data = ...;
.
.
.
// 3) pass the byte array to the web service "Generate" operation
com.edixmlonline.www.ReturnPacket pckt = service.Generate(data,
txtSEFId.Text, txtSessionID.Text);
// Reference the returned EDI contents (as a byte array)...
byte[] ediData = pckt.Payload;
System.Text.ASCIIEncoding encoding =
new ASCIIEncoding();
txtEDIContent.Text
= encoding.GetString(ediData);
Translating an EDI file is also done in a few simple stages
// 1) convert the file to a byte array
byte[] data = ...;
// 2) pass the byte array (file) and file name to the web service
com.edixmlonline.www.ReturnPacket
pckt = service.Translate(data, txtSEFId.Text, txtSessionID.Text);
// 3) Reference the Xml contents as a bytearray
byte[] xmlData = pckt.Payload;
.
.
.
// 4) Create an EDI document (referencing) object
SEF850.EdiDocument ediDoc =
new SEF850.EdiDocument();
// 5) Deserialize the Xml string in memory into the EDI document object and query object
properties
.
.
.
|