Experiment of IFBO as a web service client (.Net C#)

//Visual Studio 2008 C# console application
//
//Create the web service stubs using IFBO's WSDL:
// Solution Explorer, right click, select Add Service Reference
// Address: https://server:port/jaxws-ifbo-wsdl-xml-secure/ifboService?wsdl
// NameSpace: ifbo_wsdl_xml_secure
// Click Go.
//
//Define the IFBO's certificate to the Windows machine running this program:
// Start, Run, MMC (your Microsoft Management Console might vary from the below instructions)
// File/Add-Remove Snap-In
// Click Add
// Select Certificates and click Add
// Click Close, Click OK
// Select Certificates under Trusted Root Certification Authorities and right click on it and chose All Tasks->Import
// Specify the file name as the certificate copied from server. "server.certificate"
// Chose all the default options and click finish
// MMC is giving access to Windows settings. Once the certificate is added under Trusted Root Certification Authorities, you're done.
// Ref for MMC: http://cwiki.apache.org/ETCH/howto-tls.html
//
// PassPortGeek.com Winter 2009

using System;
using System.Web;
using System.Collections.Generic;
using System.Text;
using assetsuite.ifbo_wsdl_xml_secure;

namespace BPA {

  public class ifboWsdlXmlSec {

    public ifboWsdlXmlSec() {
    }

    public void Run() {

      String hello = "Hello World";
      Console.WriteLine(hello);

      }

    static void Main() {

      // create an instance
      ifboWsdlXmlSec ifbo = new ifboWsdlXmlSec();

      // invoke the instance method
      ifbo.Run();

      IfboServicePortType port = new IfboServicePortTypeClient();

      ifboServiceRequest hs = new ifboServiceRequest();
      hs.ifboService = new ifboService();
      //IFBO XML for Work Order create. This program is not pretty, just a proof.
      string IFBOXML = String.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE InboundRequest [ <!ELEMENT InboundRequest (APIHeader, BusinessObject)< >!ENTITY % APIHeader SYSTEM \"http://apifw//xml/APIHeader.Inbound.Request.V060000.dtd\"> %APIHeader; <!ENTITY % BusinessObject SYSTEM \"http://apifw//xml/WorkOrder.Create.Request.V060000.dtd\"> %BusinessObject; ]><InboundRequest><APIHeader ReplyTypeOK=\"A\" ReplyTypeError=\"N\"><apiAPIVersion>V060000</apiAPIVersion><apiBusinessObject>WorkOrder</apiBusinessObject><apiBusObjectMethod>Create</apiBusObjectMethod><apiBusObjectVersion>V060000</apiBusObjectVersion><apiUserID>PASSPORTID</apiUserID><apiExtSystemID></apiExtSystemID><apiExtRequestID></apiExtRequestID><apiRoutingInfo></apiRoutingInfo></APIHeader><BusinessObject><WoHeader><Facility>TIG</Facility><WorkOrderType>CA</WorkOrderType><WoDescription>Test123 IFBO</WoDescription><Planner>PASSPORTID</Planner><WoPriority>99</WoPriority><ProjectNbr>0001066</ProjectNbr></WoHeader></BusinessObject></InboundRequest>");

      char[] myChar = IFBOXML.ToCharArray();

      try {
        hs.ifboService.ifboXml = new string(myChar).ToString();
      } catch(NullReferenceException nre) {
        Console.WriteLine("Exception occured" + nre.ToString());
      }

      ifboServiceResponse1 iSR = new ifboServiceResponse1();
      iSR = port.ifboService(hs);
      Console.WriteLine(iSR.ifboServiceResponse.@return);

    }

  }
}

Reply