| By Stanimir Stanev, Rob Bartlett | Article Rating: |
|
| March 3, 2008 06:00 AM EST | Reads: |
14,220 |
Next, we attach the SOAP as a byte array to a message and send it to the queue/topic.
IBytesMessage message = session.CreateBytesMessage();
message.Content = bytBody;
//Give the address of our temporary queue
// so the service knows where to send the response
message.NMSReplyTo = queue;
using (IMessageProducer producer = session.CreateProducer())
{ NmsDestinationAccessor destinationResolver = new NmsDestinationAccessor();
IDestination destination = destinationResolver.ResolveDestinationName(session, _queueName);
producer.Send(destination, message);
}
Now we wait for a response. We set a timeout (as a TimeSpan). Here it's a fixed value of 10 seconds for illustration, but it could easily come from a config file or passed as a property in the ActiveMqWebRequestCreate.
IBytesMessage response = (IBytesMessage)
consumer.Receive(
TimeSpan.FromSeconds(10))
as IBytesMessage;
stream = new MemoryStream();
stream.Write(response.Content, 0, response.Content.Length);
} } }
catch (NMSException e)
{ throw (e); }
finally
{ m_RequestStream.InternalClose(); }
ActiveMqQueueWebResponse resp = new ActiveMqQueueWebResponse();
Here we set the stream to our own.
resp.SetDownloadStream(stream);
return resp;
}
Our ActiveMqWebResponse class inherits System.Net.WebResponse and does little more than provide a setter and override the getter on the response stream, since the stream in the built-in WebResponse is read-only.
public class ActiveMqQueueWebResponse : WebResponse
{
private Stream m_ResponseStream;
private long m_lngContentLength;
...
internal void SetDownloadStream(Stream vobjResponseStream)
{ m_ResponseStream = vobjResponseStream;
m_ResponseStream.Position = 0; // Rewind the stream
m_lngContentLength = m_ResponseStream.Length;
}
public override Stream GetResponseStream()
{ return m_ResponseStream;
} }
ActiveMqWebRequestCreate
ActiveMqWebRequestCreate
is a class that is used to create instances of our objects instead of
the built-in ones for a particular URI prefix. We'll see how this is
used in the client application.
public class ActiveMqQueueWebRequestCreate : IWebRequestCreate
{
This has the same properties that are on the ActiveMqWebRequest so it can set them when it instantiates the requests.
...
public WebRequest Create(System.Uri uri)
{ ActiveMqQueueWebRequest request = new ActiveMqQueueWebRequest(
uri, _queueAddress, _queueName, _username, _password);
return request;
} }
Published March 3, 2008 Reads 14,220
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Stanimir Stanev
Stanimir Stanev is a senior consultant at MomentumSI's Enterprise Architecture Solutions practice. He has many years of experience focusing on providing enterprise architecture and strategy expertise to companies looking to migrate to or maximize the advantages of SOA principles.
More Stories By Rob Bartlett
Rob Bartlett is a senior consultant at MomentumSI's Software Development Solutions practice. He has over a decade of experience in technical roles, guiding major corporations in the design, implementation, and integration of business solutions.
- Kindle 2 vs Nook
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Windows 7 – Microsoft’s First Step to the Cloud
- Cloud Expo and the End of Tech Recession
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Reality Check at the Cloud Computing Expo
- Visual Studio 2010 Is Cloud Friendly
- Fired SCO CEO Fires Back
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Cloud Computing Best Practices
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Eval JavaScript in a Global Context
- Windows 7 – Microsoft’s First Step to the Cloud
- Google Maps and ASP.NET
- Crystal Reports XI & How It Has Changed
- Converting VB6 to VB.NET, Part I
- Creating Controls for.NET Compact Framework in Visual Studio 2005
- Where Are RIA Technologies Headed in 2008?
- How to Write High-Performance C# Code
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Implementing Tab Navigation with ASP.NET 2.0
- i-Technology Photo Exclusive: Bill Gates & Steve Jobs In "Nerds"
- .NET Archives: Getting Reacquainted with the Father of C#
- i-Technology Viewpoint: "SOA Sucks"
- Programmatically Posting Data to ASP .NET Web Applications



























