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.Protoc
ols;
using System;
using System.Xml.Serialization;
using System.Web;
using System.Xml;
using System.Xml.Schema;
using IBM.WMQ;
/// <remarks/>
[System.CodeDom.Compiler.G
eneratedCo
deAttribut
e("System.
Web.Servic
es", "2.0.50727.42")]
[System.Web.Services.WebSe
rviceAttri
bute(Names
pace="
http://www.starstandards.org/webservices/2005/10/transport/bindings")]
[System.Web.Services.WebSe
rviceBindi
ngAttribut
e(Name="st
arTranspor
t", Namespace="
http://www.starstandards.org/webservices/2005/10/transport/bindings")]
public partial class WebService : System.Web.Services.WebSer
vice, IWebService
{
[System.Xml.Serialization.
XmlElement
Attribute(
ElementNam
e="payload
Manifest")
]
public PayloadManifest payloadManifest;
public WebService()
{
}
public WebService(PayloadManifest
payloadManifest)
{
this.payloadManifest = payloadManifest;
}
/// <remarks/>
[System.Web.Services.Proto
cols.SoapH
eaderAttri
bute("payl
oadManifes
t", Direction=System.Web.Servi
ces.Protoc
ols.SoapHe
aderDirect
ion.InOut)
]
[System.Web.Services.WebMe
thodAttrib
ute()]
[System.Web.Services.Proto
cols.SoapD
ocumentMet
hodAttribu
te("
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.De
scription.
SoapBindin
gUse.Liter
al, ParameterStyle=System.Web.
Services.P
rotocols.S
oapParamet
erStyle.Wr
apped, Binding="starTransport")]
public virtual void ProcessMessage([System.Xml
.Serializa
tion.XmlEl
ementAttri
bute(Eleme
ntName="pa
yload")] 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(o
bject 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_CLI
ENT;
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(M
QC.TRANSPO
RT_PROPERT
Y, connectionType);
// Setup the rest of the connection properties, based on connection type requested
switch(connectionType)
{
case MQC.TRANSPORT_MQSERIES_BIN
DINGS:
break;
case MQC.TRANSPORT_MQSERIES_CLI
ENT:
connectionProperties.Add(M
QC.HOST_NA
ME_PROPERT
Y, hostName);
connectionProperties.Add(M
QC.CHANNEL
_PROPERTY,
channel);
connectionProperties.Add(M
QC.PORT_PR
OPERTY, 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.Q
UEUE", openOptions);
// Define a Websphere MQ Message
MQMessage xmlPayload = new MQMessage();
xmlPayload.WriteString(Xml
Doc);
// Specify the message options
MQPutMessageOptions pmo = new MQPutMessageOptions(); // Accept the default
// Put the Message on the Queue
wsTransport_in_queue.Put(x
mlPayload,
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.Proto
cols.SoapH
eaderAttri
bute("payl
oadManifes
t")]
[System.Web.Services.WebMe
thodAttrib
ute()]
[System.Web.Services.Proto
cols.SoapD
ocumentMet
hodAttribu
te("
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.De
scription.
SoapBindin
gUse.Liter
al, ParameterStyle=System.Web.
Services.P
rotocols.S
oapParamet
erStyle.Wr
apped, Binding="starTransport")]
public virtual void PutMessage([System.Xml.Ser
ialization
.XmlElemen
tAttribute
(ElementNa
me="payloa
d")] Payload payload)
{
throw new System.NotImplementedExcep
tion();
}
/// <remarks/>
[System.Web.Services.Proto
cols.SoapH
eaderAttri
bute("payl
oadManifes
t", Direction=System.Web.Servi
ces.Protoc
ols.SoapHe
aderDirect
ion.Out)]
[System.Web.Services.WebMe
thodAttrib
ute()]
[System.Web.Services.Proto
cols.SoapD
ocumentMet
hodAttribu
te("
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.De
scription.
SoapBindin
gUse.Liter
al, ParameterStyle=System.Web.
Services.P
rotocols.S
oapParamet
erStyle.Wr
apped, Binding="starTransport")]
[return: System.Xml.Serialization.X
mlElementA
ttribute("
payload")]
public virtual Payload PullMessage()
{
throw new System.NotImplementedExcep
tion();
}
}
}
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\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(76,2
0): error CS1513: } expected
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(102,
20): error CS1519: Invalid token 'int' in class, struct, or interface member declaration
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(169,
24): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(169,
110): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(171,
23): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(179,
24): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(181,
23): error CS1518: Expected class, delegate, enum, interface, or struct
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(182,
9): error CS1022: Type or namespace definition, or end-of-file expected
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(168,
435): error CS0106: The modifier 'virtual' is not valid for this item
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.cs(169,
108): error CS0101: The namespace 'wsTransport' already contains a definition for '?'
e:\projects\transWSEngine\
App_Code\S
TARTranspo
rt2005Arko
naMS\servi
ce.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