help with xml request

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • donnovan
    New Member
    • May 2011
    • 2

    #1

    help with xml request

    hi all,

    i am trying to send request over tcp to cummunicate with a CCV POS Engine.

    but i keep on getting this error
    System.InvalidO perationExcepti on:In XML-document (2, 2)System.Invali dOperationExcep tion: <ServiceReque st xmlns='http://www.nrf-arts.org/IXRetail/namespace'> not expected.

    if i dont send this attribute i get the same error:
    system.invalid. opratorexceptio n xmlns="" was not expected.

    any ideas?


    this is my code im working in VS 2010 using C# .net microframework

    Code:
     public static byte[] LoginRequest()
            {
                MemoryStream ms = new MemoryStream();
                XmlWriter xmlwrite = XmlWriter.Create(ms);
    
                xmlwrite.WriteString("\r");
                xmlwrite.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
                
                xmlwrite.WriteStartElement("ServiceRequest");
                xmlwrite.WriteAttributeString("WorkstationID", WorkstationId); 
                xmlwrite.WriteAttributeString("RequestID", "1");
                xmlwrite.WriteAttributeString("RequestType", "Login");
                xmlwrite.WriteAttributeString("xmlns","http://www.nrf-arts.org/IXRetail/namespace");
    
                xmlwrite.WriteString("\r\t");
                xmlwrite.WriteStartElement("POSdata");
                xmlwrite.WriteAttributeString("LanguageCode", "nl");
    
                xmlwrite.WriteString("\r\t\t");
                xmlwrite.WriteStartElement("POSTimeStamp");
                xmlwrite.WriteString(time);
                xmlwrite.WriteEndElement();
    
                xmlwrite.WriteString("\r\t\t");
                xmlwrite.WriteStartElement("ShiftNumber");
                xmlwrite.WriteString("0");
                xmlwrite.WriteEndElement();
    
                xmlwrite.WriteString("\r\t\t");
                xmlwrite.WriteStartElement("PrinterStatus");
                xmlwrite.WriteString("Unavailable");
                xmlwrite.WriteEndElement();
    
                xmlwrite.WriteString("\r\t");
                xmlwrite.WriteEndElement();     // End POSdata
                xmlwrite.WriteString("\r");
                xmlwrite.WriteEndElement();    // End root ServiceRequest
    
                xmlwrite.Flush();
                byte[] byteArray = ms.ToArray();
                xmlwrite.Close();
    
                //////// display the XML data ///////////
                
                char[] cc = System.Text.UTF8Encoding.UTF8.GetChars(byteArray);
                string str = new string(cc);
                Debug.Print(str);
    
                return byteArray;
            }
    and this i how the xml output should look like

    <?xml version="1.0" encoding="utf-8"?>
    <ServiceReque st WorkstationID=" POS" RequestID="57" RequestType="Lo gin" xmlns="http://www.nrf-arts.org/IXRetail/namespace">
    <POSdata LanguageCode="n l">
    <POSTimeStamp>2 007-03-21T14:11:14.375 +01:00</POSTimeStamp>
    <ShiftNumber> 0</ShiftNumber>
    <PrinterStatus> Available</PrinterStatus>
    </POSdata>
    </ServiceRequest>

    thnx
  • donnovan
    New Member
    • May 2011
    • 2

    #2
    i found the problem, i was using the wrong endpoint.

    Comment

    Working...