Problem with Streams - Converting VB Code to C#

deV.chdeV.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:
        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?

Comments

  • deV.chdeV.ch Member Posts: 543
    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...
Sign In or Register to comment.