Clarity

 View Only
  • 1.  VB.NET SOAP Integration Sample for Ideas

    Posted Jul 30, 2012 09:17 PM
    Brother, can you spare a Solution?

    I'm preparing a web service integration demo for our SharePoint team on writing ideas to Clarity. I have a SOAPUI demo ready, but I'd prefer something that speaks their language better, such as a super simple VB.NET Windows Form Visual Studio project or solution.

    I'm looking to create an idea with the bare minimum - Idea name & Idea description. No error handling or SOAP responses necessary, just a little something to speed the 'ah HA' moment. See form below, I'll spare ya the pain (and my shame) of posting my current VB code...

    .


  • 2.  RE: VB.NET SOAP Integration Sample for Ideas

     
    Posted Aug 02, 2012 07:21 PM
    Hi All,

    Any help here for brother Rob?

    Thanks!
    Chris


  • 3.  RE: VB.NET SOAP Integration Sample for Ideas

    Posted Aug 07, 2012 01:00 PM
    I'm not really a VB.NET guy, haven't touched VB since version 6, but I'm to understand that people experienced with it wouldn't have much trouble reading/translating between it and C#, which to do only what is asked here would look something like this (all the code has just been dumped into the button's action/event handler routine):
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;[color=#554dc9]
    using IdeaSubmissionDemo.IdeaService; // IdeaService is the name I gave to the Service Reference added to the project pointing to http://myserver/niku/wsdl/Object/Ideas
    using System.Xml;
    using System.ServiceModel;
    using System.ServiceModel.Description;[color]
    namespace IdeaSubmissionDemo {     public partial class IdeaForm : Form     {         public IdeaForm()         {             InitializeComponent();         } [color=#554dc9]
    private void SubmitIdea_Click(object sender, EventArgs e)
    {
    IdeasPortClient ipc = new IdeasPortClient();
    IdeasPort ip = ipc.ChannelFactory.CreateChannel(new EndpointAddress(Properties.Settings.Default.endpoint));

    // Logging in
    Login creds = new Login();
    creds.Username = Properties.Settings.Default.username;
    creds.Password = Properties.Settings.Default.password;

    Auth auth = new Auth();
    LoginRequest loginRequest = new LoginRequest(creds);
    auth.SessionID = ip.Login(loginRequest).SessionID;

    // Populating idea submission details
    XmlDocument request = new XmlDocument();
    request.LoadXml(@"<NikuDataBus xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
    xsi:noNamespaceSchemaLocation=""../xsd/nikuxog_idea.xsd"">
    <Header action=""write"" externalSource=""NIKU"" objectType=""idea"" version=""8.0""/>
    <Ideas>
    <Idea objectID=""temp"" lastUpdatedBy=""admin""
    lastUpdatedDate=""2006-02-17T12:06:10"" managerUserName=""admin""
    status=""0"" name=""temp"" description=""temp"">
    <CustomInformation>
    <ColumnValue name=""partition_code"">NIKU.ROOT</ColumnValue>
    </CustomInformation>
    </Idea>
    </Ideas>
    </NikuDataBus>");

    XmlNode node = request.SelectSingleNode("//@objectID");
    node.Value = IdeaName.Text; // Note: Reused name as the ID, handle/populate this better in a 'for real' case

    node = request.SelectSingleNode("//@name");
    node.Value = IdeaName.Text;

    node = request.SelectSingleNode("//@description");
    node.Value = IdeaDescription.Text;

    node = request.SelectSingleNode("//@lastUpdatedDate");
    node.Value = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");

    Console.WriteLine("-------------------------------------------------------------");
    Console.WriteLine("Request: ");
    Console.WriteLine(request.OuterXml);


    // Submitting idea
    WriteIdeaRequest ideaRequest = new WriteIdeaRequest(auth, request.DocumentElement);
    WriteIdeaResponse ideaResponse = ip.WriteIdea(ideaRequest);

    Console.WriteLine("Response: ");
    Console.WriteLine(ideaResponse.WriteIdeaResponse1.OuterXml);

    // Logging out -- exception handling needed at minimum since a non/null response is sort of unexpected here
    try
    {
    ip.Logout(auth.SessionID);
    }
    catch (ProtocolException)
    {
    // ignore throw;
    }
    catch (Exception)
    {
    throw;
    }

    // Report success or fail or otherwise here
    // ...
    }[color]
        } }
    To make it flexible enough to handle different endpoints (otherwise running it would fail for you without regenerating the service proxy code again, since you can't connect to my endpoint), the code isn't quite as trivial as it could otherwise have looked, but it's still relatively small and simple.

    Attached are the project files (sources, properties, and debug binary).

    To change the username, password, and endpoint to your own needed values, change the Settings.settings file contents in the Solution Explorer window of Visual Studio.

    I hope that will do!

    Edit: Emboldened the code that was added to the initial boiler template Form code given to you by default.


  • 4.  RE: VB.NET SOAP Integration Sample for Ideas

    Posted Aug 08, 2012 09:23 PM
    Absolutly Awesome!

    Thanks Nick!

    .


  • 5.  RE: VB.NET SOAP Integration Sample for Ideas

    Posted Aug 08, 2012 10:43 PM
    Hi all.
    I think this would be an awesome integration demo to add to the XOG Developer Guide. Please Comment & Promote if you think adding this C# 'Idea Submission Demo' to the XOG Developer Guide would enhance the product and provide value to your organization.

    [size=5] Click Here for Idea: Add C# 'Idea Submission Demo' to Integration Guide.[size].