Error while calling a codeunit from action pane in RTC

prabhupdeshprabhupdesh Member Posts: 49
edited 2010-03-31 in NAV Three Tier
Hi all,

I have created a codeunit which is called from action pane in customer card. But while calling from action pane i am getting following error as mentioned below:
"The server "net.[url=tcp://localhost:7046/DynamicsNAV/Service]tcp://localhost:7046/DynamicsNAV/Service[/url]" is either unavailable or your connection has been lost. Do you want to attempt to reconnect".

On clicking YES on the error dialog box the RTC simply closes and gives a second eror message as below:
"The connection to the server is lost.The application will close."

This functionality is working fine in classic client.

Please help!!!

Answers

  • ara3nara3n Member Posts: 9,255
    what is this codeunit doing?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • prabhupdeshprabhupdesh Member Posts: 49
    Hi,

    Thanks for the response.

    This codeunit is performing the following tasks:

    1.First, it exports some data(in customer table) using xmlport.
    2.Then it send the xml using http post method to a webservice
    3.Then it receives the response from the webservice and imports the data in a table using xml port

    This whole functionality is working well in classic client, only when I try doing it in RTC, that i receive the said message.

    Please find a code part:

    CLEAR(TempBlob);
    TempBlob.Blob.CREATEOUTSTREAM(Ostream);
    XmlPort.SetCurrencyCodes(Para A,Para B,Para C);
    XmlPort.SETDESTINATION(Ostream);
    XmlPort.EXPORT;// if i comment & rest of the code after message('hi') ,then i dont get the error message and i receive 'hi' message.
    Message('hi');
    .......rest of the code to call 'send soap message'..

    Please help.
  • ara3nara3n Member Posts: 9,255
    does you xmlport have namespaces in it?

    It looks like the service tier is crashing. Check the eventlog on service tier.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • prabhupdeshprabhupdesh Member Posts: 49
    Yes , i am using name space.

    Following is the message found in the log:

    Service: MicrosoftDynamicsNavServer
    User: adder\Admin
    Type: System.ArgumentException
    Message: Invalid name character in 'soap:Envelope'. The ':' character, hexadecimal value 0x3A, cannot be included in a name.
  • ara3nara3n Member Posts: 9,255
    I suggest to remove the namespaces from the xmlport.

    After you run Xmlport.export

    Load the stream into MSXMLDocument.

    create a function that will add namespaces and return a new DOM Object.

    Then send that to web services.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • prabhupdeshprabhupdesh Member Posts: 49
    thanks.let me try this, will revert back soon
  • prabhupdeshprabhupdesh Member Posts: 49
    Thanks.SOLVED
  • ara3nara3n Member Posts: 9,255
    edit the first post and change the option below the tile to solved.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • jpjesusjpjesus Member Posts: 45
    Hi prabhupdesh,

    Would it be possible for you to post a sample of the code you are using to do this?

    I run into the same problem but I am not being able to getting it to work, so I would appreciate any help with a code sample.

    thanks in advance
  • ara3nara3n Member Posts: 9,255
    XML is a blob field. You can use Tempblob table.
    XML.CREATEOUTSTREAM(outstr);
    POXMLPort.SetHeader(PurchHeader);
    POXMLPort.SETDESTINATION(outstr);
    POXMLPort.EXPORT;
    
    CALCFIELDS(XML);
    
    IF NOT XML.HASVALUE THEN
      EXIT;
    XML.CREATEINSTREAM(instr);
    //XML.EXPORT('c:\nav\xmlblob.xml');  //if you want to see the xml file.
    
    MSDOM.async := FALSE;
    MSDOM.load(instr);
    
    
    AddNamespace(MSDOM);
    
    //now msdom has the namespaces and you can send it or save it
    //MSDOM.save('c:\test.xml');
    //XMLHTTP.send(MSDOM);  
    

    AddNamespace looks like this, but in your case it will be different depending on how your xml file looks like.
    AddNamespace(VAR MSDOM2 : Automation "'Microsoft XML, v6.0'.DOMDocument")
    IF ISCLEAR(MSDOM) THEN BEGIN
      CREATE(MSDOM);
      MSDOM.async := FALSE;
    END;
    
    XMLNode2 := MSDOM2.documentElement.selectSingleNode('/NAV/Header/MessageType');
    MsgType := XMLNode2.text;
    Ch10 := 10;
    CH13 := 13;
    CH9 := 9;
    Separator := FORMAT(CH13) + FORMAT(Ch10) + FORMAT(CH9);
    
    MSDOM.loadXML('<?xml version="1.0" encoding="utf-8"?>' + Separator
     + '<ns1:NAV xmlns:ns0="http://NAV.NAV.SharedSchemas.Schemas/Header" '
     + 'xmlns:ns1="http://NAV.NAV.SharedSchemas.Schemas/'+MsgType+'">' + Separator
     + '<ns0:Header>' + Separator + '</ns0:Header>' + Separator + '</ns1:LSR>');
    
    XMLNode := MSDOM.documentElement.firstChild;
    XMLNode2 := MSDOM2.documentElement.selectSingleNode('/NAV/Header/MessageId');
    XMLNode.appendChild(XMLNode2);
    XMLNode2 := MSDOM2.documentElement.selectSingleNode('/NAV/Header/DateCreated');
    XMLNode.appendChild(XMLNode2);
    XMLNode := MSDOM.documentElement;
    XMLNode2 := MSDOM2.documentElement.selectSingleNode('/NAV/Message');
    XMLNode.appendChild(XMLNode2);
    
    MSDOM2 := MSDOM;
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • prabhupdeshprabhupdesh Member Posts: 49
    Hi,

    The solution worked initially but started giving the same problem when we did some more modification. Finally i found that the error arised when xml port(meant for exporting the data & create a xml file) was called, so instead of calling the xml port to export the data & create an xml file, I exported the data and created the xml in the way as shown below:


    CREATE(XmlEnv);
    XmlEnv.preserveWhiteSpace := FALSE;

    XmlEnv.loadXML(
    '<?xml version="1.0" encoding="utf-8"?>' +
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; ' +
    ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
    ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
    ' <soap:Body>' +
    ' <getNameRequest xmlns="http://Abcd.com&quot; xmlns:doc="http://abcd.com">' +
    ' <add>'+
    ' <city>'+PC+'</city>'+
    ' <postCd>'+Pd+'</postCd>'+
    ' </add>'+
    ' </getNameRequest>'+
    ' </soap:Body>'+
    ' </soap:Envelope>');

    where pc,pd are the variables containing data.,

    Thanks,
    Prabh
  • prabhupdeshprabhupdesh Member Posts: 49
    let me also try with the solution given by ar3n
  • navinbnavinb Member Posts: 51
    I think these can be done using UseDefaultNamespace and DefaultNamespace properties of XMLPort ?
  • jpjesusjpjesus Member Posts: 45
    Hi

    @navinb
    I don't think that one can use those properties in this case. As far as I could read on several forums these properties can only be applied to a single namespace. If you have more than one, like I do, it won't work.

    @All
    Another thing I manage to find out is that this is not directly related to namespaces. I removed all references to namespaces that I was using on my XMLPort, as well to the SOAP.
    If a single TAG as the character ":" in it, this error will pop up in the RTC. In my case, bcause the webservices I have to invoke use something like "cdp:ItemCode" in all tags, I need to use the ":" in all tags..... darn :)

    Not sure that I can persuade the WebServices provider into changing the tags.....
Sign In or Register to comment.