Problem with Streams - Converting VB Code to C#
 
            
                
                    deV.ch                
                
                    Member Posts: 543                
            
                        
            
                    Hi Everybody,
I'am trying to convert an old vb asp script to convert to asp.net
Now here is the old asp code:
I had a lot problems with the Type of Streams, when i tried to write that code in C#. Can anyone convert that code to c# for me?
How can i us de XMLDocument.Load() Method with the Stream from the InMsg and OutMsg?
                I'am trying to convert an old vb asp script to convert to asp.net
Now here is the old asp code:
        Set ComCom = Server.CreateObject("NSComCom2.CommunicationComponent")
	Set SBA = Server.CreateObject("SocketBusAdapter.SocketBusAdapter")
	SBA.ReceivingTimeout = 200000
	Set InMsg = Server.CreateObject("MSMQBusAdapter.InMessage")
	Set OutMsg = Server.CreateObject("MSMQBusAdapter.OutMessage")
	ComCom.AddBusAdapter SBA,0
	Set OutMsg = ComCom.CreateoutMessage("Sockets://" & ServKonf.getActNASHostAndPort)
	sendDOM.Save OutMsg.GetStream()
	Set InMsg = OutMsg.SendWaitForReply(0)
        
        RespDOM.async = False
	RespDOM.Load(InMsg.GetStream())
  	InMsg.CommitMessage
I had a lot problems with the Type of Streams, when i tried to write that code in C#. Can anyone convert that code to c# for me?
How can i us de XMLDocument.Load() Method with the Stream from the InMsg and OutMsg?
0                
            Comments
- 
            OK i got it know to work... in a strange way:
 Only if i pass simple requests i get an answer, if i pass a big XML Request, than it loses connection to the InMsg Stream and i get this error:
 (Ausnahme von HRESULT: 0x80030102 (STG_E_REVERTED))
 That happens when the COMXMLDocument tries to read from the InMsg Stream
 Here is the Code:
 COMXMLDocument COMResponse = new COMXMLDocument(); try { NSCOMCOM2Lib.CommunicationComponentClass ComCom = new CommunicationComponentClass(); SOCKETBUSADAPTERLib.SocketBusAdapterClass SBA = new SOCKETBUSADAPTERLib.SocketBusAdapterClass(); SBA.ReceivingTimeout = 200000; ComCom.AddBusAdapter(SBA, 0); OutMsg = ComCom.CreateoutMessage("Sockets://" + ServKonf.getActNASHostAndPort()) as NSCOMCOM2Lib.IOutMessage; COMXMLDocument COMXmlDoc = new COMXMLDocument(); COMXmlDoc.LoadXml(sendDOM.InnerXml); COMXmlDoc.Save(OutMsg.GetStream() as System.Runtime.InteropServices.UCOMIStream); InMsg = OutMsg.SendWaitForReply(10000) as NSCOMCOM2Lib.IInMessage; if (InMsg != null) COMResponse.Load(InMsg.GetStream() as System.Runtime.InteropServices.UCOMIStream); respDOM.LoadXml(COMResponse.InnerXml); InMsg.CommitMessage(); }
 Whats the problem here? Why do small requests work and big ones don't? The old asp Script works just fine...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions