Advertisement

07.19.2007 at 12:54PM PDT, ID: 22708149
[x]
Attachment Details

.Net C# web service with Websphere MQ adding message to a queue error in code please help

Asked by jareddraper in Application Servers, .NET, C# Programming Language

Tags: mq

I am having a problem implementing a Websphere MQ put command into my .Net C# webservice. Here is my code and help would be great.

#region WSCF
//------------------------------------------------------------------------------
// <autogenerated code>
//     This code was generated by a tool.
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </autogenerated code>
//------------------------------------------------------------------------------
// File time 18-07-07 03:10 PM
//
// This source code was auto-generated by WsContractFirst, Version=0.7.6319.1
#endregion


namespace wsTransport
{
      using System.Diagnostics;
      using System.Web.Services;
      using System.ComponentModel;
      using System.Web.Services.Protocols;
      using System;
      using System.Xml.Serialization;
      using System.Web;
      using System.Xml;
      using System.Xml.Schema;
      using IBM.WMQ;
      
      
      /// <remarks/>
      [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42")]
      [System.Web.Services.WebServiceAttribute(Namespace="http://www.starstandards.org/webservices/2005/10/transport/bindings")]
      [System.Web.Services.WebServiceBindingAttribute(Name="starTransport", Namespace="http://www.starstandards.org/webservices/2005/10/transport/bindings")]
      public partial class WebService : System.Web.Services.WebService, IWebService
      {
            
            [System.Xml.Serialization.XmlElementAttribute(ElementName="payloadManifest")]
            public PayloadManifest payloadManifest;
            
            public WebService()
            {
            }
            
            public WebService(PayloadManifest payloadManifest)
            {
                  this.payloadManifest = payloadManifest;
            }
            
            /// <remarks/>
            [System.Web.Services.Protocols.SoapHeaderAttribute("payloadManifest", Direction=System.Web.Services.Protocols.SoapHeaderDirection.InOut)]
            [System.Web.Services.WebMethodAttribute()]
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/wsTransport/service/ProcessMessage", RequestNamespace="http://www.starstandards.org/webservices/2005/10/transport", ResponseNamespace="http://www.starstandards.org/webservices/2005/10/transport", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Binding="starTransport")]
            public virtual void ProcessMessage([System.Xml.Serialization.XmlElementAttribute(ElementName="payload")] ref Payload payload)
            {
                  // Here is the Code that reads the XML Payload Stream and Validates it to the correct Schema before sending the message forward.

                  System.Xml.XmlElement xe = payload.content[0].Any;
                  XmlDocument xmlDoc = xe.OwnerDocument;
                  xmlDoc.Schemas.Add(null, "http://localhost/wsTransport/ProcessCreditContract.xsd");
                  xmlDoc.Validate(delegate(object sender, ValidationEventArgs vargs)
                  {
                        Console.WriteLine("{0}: {1}", vargs.Severity, vargs.Message);
                  }, xe);


                  // Websphere MQ Series Connection to dump payload to queue


                  const String connectionType = MQC.TRANSPORT_MQSERIES_CLIENT;
                  const String qManager = "ARKDEV.QUEUE.MANAGER";
                  const String hostName = "arkdev.arkona.com";
                  const String channel = "SYSTEM.ADMIN.SVRCONN";
                  const String port = "1414";

                  // Initialise the connection properties for the type requested

                  Static Hashtable init(String connectionType)
                  {
                        Hashtable connectionProperties = new Hashtable();

                        // Add the connection type

                        connectionProperties.Add(MQC.TRANSPORT_PROPERTY, connectionType);

                        // Setup the rest of the connection properties, based on connection type requested

                        switch(connectionType)
                        {
                              case MQC.TRANSPORT_MQSERIES_BINDINGS:
                                    break;
                              case MQC.TRANSPORT_MQSERIES_CLIENT:
                                    connectionProperties.Add(MQC.HOST_NAME_PROPERTY, hostName);
                                    connectionProperties.Add(MQC.CHANNEL_PROPERTY, channel);
                                    connectionProperties.Add(MQC.PORT_PROPERTY, port);
                                    break;
                        }

                        return connectionProperties;
                  }

                  // The Main Entry point for Websphere MQ

                  Static int Main(String[] args)
                  {
                        try
                        {
                              Hashtable connectionProperties = init(connectionType);

                              // Create a connection to the Queue manager using the connection properties just defined

                              MQQueueManager qMgr = new MQQueueManager(qManager, connectionProperties);

                              // Set up the options on the queue we wish to open

                              int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;

                              // Now we specify the queue that we wish to open

                              MQQueue wsTransport_in_queue =
                                    qMgr.AccessQueue("ROB.IN.QUEUE", openOptions);

                              // Define a Websphere MQ Message

                              MQMessage xmlPayload = new MQMessage();
                              xmlPayload.WriteString(XmlDoc);

                              // Specify the message options

                              MQPutMessageOptions pmo = new MQPutMessageOptions(); // Accept the default

                              // Put the Message on the Queue

                              wsTransport_in_queue.Put(xmlPayload, pmo);

                              // Close the Queue

                              wsTransport_in_queue.Close();

                              // Disconnect from Queue Manager

                              qMgr.Disconnect();
                        }

                        // If an error has occurred in the above, try to identify what went wrong.

                        // Was it a Websphere MQ error?

                        catch (MQException ex)
                        {
                              Console.WriteLine("A Websphere MQ error occurred: {0}", ex.ToString());
                        }

                        catch (SystemException ex)
                        {
                              Console.WriteLine("A system error occurred: {0}", ex.ToString());
                        }

                        return 0;


                  }


            }
            
            /// <remarks/>
            [System.Web.Services.Protocols.SoapHeaderAttribute("payloadManifest")]
            [System.Web.Services.WebMethodAttribute()]
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/wsTransport/service/PutMessage", RequestNamespace="http://www.starstandards.org/webservices/2005/10/transport", ResponseNamespace="http://www.starstandards.org/webservices/2005/10/transport", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Binding="starTransport")]
            public virtual void PutMessage([System.Xml.Serialization.XmlElementAttribute(ElementName="payload")] Payload payload)
            {
                  throw new System.NotImplementedException();
            }
            
            /// <remarks/>
            [System.Web.Services.Protocols.SoapHeaderAttribute("payloadManifest", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)]
            [System.Web.Services.WebMethodAttribute()]
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/wsTransport/service/PullMessage", RequestNamespace="http://www.starstandards.org/webservices/2005/10/transport", ResponseNamespace="http://www.starstandards.org/webservices/2005/10/transport", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Binding="starTransport")]
            [return: System.Xml.Serialization.XmlElementAttribute("payload")]
            public virtual Payload PullMessage()
            {
                  throw new System.NotImplementedException();
            }
      }
}


Here is the error information when I try and build the project

------ Build started: Project: e:\projects\transWSEngine\, Configuration: Debug .NET ------
Validating Web Site

e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(76,20): error CS1513: } expected
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(102,20): error CS1519: Invalid token 'int' in class, struct, or interface member declaration
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(169,24): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(169,110): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(171,23): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(179,24): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(181,23): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(182,9): error CS1022: Type or namespace definition, or end-of-file expected
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(168,435): error CS0106: The modifier 'virtual' is not valid for this item
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(169,108): error CS0101: The namespace 'wsTransport' already contains a definition for '?'
e:\projects\transWSEngine\App_Code\STARTransport2005ArkonaMS\service.cs(178,73): error CS0106: The modifier 'virtual' is not valid for this item
Validation Complete
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========Start Free Trial
[+][-]07.19.2007 at 01:03PM PDT, ID: 19525609

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.19.2007 at 01:13PM PDT, ID: 19525693

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.19.2007 at 01:29PM PDT, ID: 19525808

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.20.2007 at 12:45AM PDT, ID: 19529336

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Application Servers, .NET, C# Programming Language
Tags: mq
Sign Up Now!
Solution Provided By: davidwainwright
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32