using xml please help me sooooooooon :)

Discussion in 'ASP .Net Web Services' started by mahsa, Apr 28, 2004.

  1. mahsa

    mahsa Guest

    hi i have this code it has error that "stream was not readable" im new in xml do you have any idea?i have to pass data to site and get the reason in xm
    regards ... mahs

    // Put user code to initialize the page her
    //Declare variable
    string bolRequest ; // a string to hold XML bolRequest document,,a string to hold XML Bill of Lading Request documen
    //stringBuffer bolResponse = new StringBuffer(50000)

    string bolResponse; //an XML DOM object to hold the BOL Response documen
    string localError ; // a string to store any Error Messages
    string status = ""; //sample variable to demonstrate how to pull values out of XML element
    string conwayXMLURL = "http://www.con-way.com/XMLj/X-BOL"
    string bolRequestFormName = "BOLrequest"

    // Con-Way authenticatio
    // *** replace the "userId" & "passWd" String values with your Con-Way username and passwor
    string userId = "uid";//for authentication to Con-Way secure sit
    string passWd = "pass";//for authentication to Con-Way secure sit
    DateTime today =new DateTime();//String to hold today's dat

    bolRequest="<BOLrequest testmode=\"Y\">"
    "<RequesterUserId shipcode=\"S\">" + userId + "</RequesterUserId>"
    "<ChargeCode>P</ChargeCode>"
    "<PRONmbr></PRONmbr>"
    "<CustRefNmbrs>"
    "<PurchaseOrderNmbr>3338889</PurchaseOrderNmbr>"
    "<PurchaseOrderNmbr>3338890</PurchaseOrderNmbr>"
    "<OtherRefNmbr refcode=\"SKU\" refdesc=\"SKU Number\">3213A</OtherRefNmbr>"
    "<OtherRefNmbr refcode=\"UPC\" refdesc=\"UPC number\">789283</OtherRefNmbr>"
    "</CustRefNmbrs>"
    "<Shipper>"
    "<ShipperName>Alan Shipley</ShipperName>"
    "<ShipperAddr>1234 NE Main</ShipperAddr>"
    "<ShipperCity>Portland</ShipperCity>"
    "<ShipperState>OR</ShipperState>"
    "<ShipperZip country=\"US\">97202</ShipperZip>"
    "<ShipperPhone extension=\"6055\">503.450.6055</ShipperPhone>"
    "<ShipperEmail></ShipperEmail>"
    "</Shipper>"
    "<COD>"
    "<CODremitTo>"
    "<CODremitToName>Albert Cod</CODremitToName>"
    "<CODremitToAddr>1234 NE Main</CODremitToAddr>"
    "<CODremitToCity>Portland</CODremitToCity>"
    "<CODremitToState>OR</CODremitToState>"
    "<CODremitToZip country=\"US\">97202</CODremitToZip>"
    "</CODremitTo>"
    "<CODamount pmttype=\"CustomerCheck\" chargecode=\"P\">4444.44</CODamount>"
    "</COD>"
    "<Consignee>"
    "<ConsigneeCustNmbr>883885</ConsigneeCustNmbr>"
    "<ConsigneePhone extension=\"6666\">503.450.6800</ConsigneePhone>"
    "<ConsigneeEmail></ConsigneeEmail>"
    "</Consignee>"
    "<Item>"
    "<Quantity pkgtype=\"PLT\">44</Quantity>" +
    "<Weight unit=\"lbs\">667</Weight>"
    "<Description>widget-arms</Description>"
    "<CmdtyClass>775</CmdtyClass>"
    "<NMFClass></NMFClass>"
    "<HazMat>N</HazMat>"
    "</Item>"
    "<Item>"
    "<Quantity pkgtype=\"PCS\">11</Quantity>" +
    "<Weight unit=\"lbs\">789</Weight>"
    "<Description>cam-shafts</Description>"
    "<CmdtyClass>100</CmdtyClass>"
    "<NMFClass></NMFClass>"
    "<HazMat>N</HazMat>"
    "</Item>"
    "<Accessorial chargecode=\"P\">GUR</Accessorial>"
    "<Accessorial chargecode=\"C\">DID</Accessorial>"
    "<Accessorial chargecode=\"C\">DST</Accessorial>"
    "<ShippingRemarks>TEST TEST TEST</ShippingRemarks>"
    "<EmergencyContact></EmergencyContact>"
    "<PickupRequest>"
    "<PickupDate>" + today + "</PickupDate>"
    "<PickupReadyTime>4:00 pm</PickupReadyTime>"
    "<DockCloseTime>7:00 pm</DockCloseTime>"
    "<ContactName>Frank</ContactName>"
    "<ContactCompany>Franklin Arms</ContactCompany>"
    "<ContactPhone>(333)444-4321</ContactPhone>"
    "</PickupRequest>"
    "<SendBOLemail/>"
    "</BOLrequest>"

    bolRequest = Server.UrlEncode(bolRequest);// converts characters to proper format for pos
    ASCIIEncoding encoding=new ASCIIEncoding()
    string authString = userId + ":" + passWd

    byte[] data = encoding.GetBytes(authString)

    HttpWebRequest myConnection = (HttpWebRequest)WebRequest.Create(conwayXMLURL);
    // Setup connection parameters
    myConnection.Method = "POST";
    myConnection.ContentType="application/x-www-form-urlencoded";
    myConnection.ContentLength = data.Length;
    myConnection.Timeout = -1;

    Stream newStream=myConnection.GetRequestStream();

    // Send the data.
    newStream.Write(data,0,data.Length);
    newStream.Flush();
    newStream.Close();

    Stream iStream=myConnection.GetRequestStream();

    StreamReader myInReader=new StreamReader(iStream);

    //int chr = myInReader.Read();
    //int responseLength = 0;
    // Build the response Stringbuffer from the InputStream
    //while (chr != -1)
    //{
    //responseLength++;
    //bolResponse.append(String.valueOf((char) chr));
    //chr = myInReader.read();
    //}
     
    mahsa, Apr 28, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    522
    Chris Uppal
    May 5, 2005
  2. Tony Prichard
    Replies:
    0
    Views:
    741
    Tony Prichard
    Dec 12, 2003
  3. KK
    Replies:
    2
    Views:
    596
    Big Brian
    Oct 14, 2003
  4. MuZZy
    Replies:
    7
    Views:
    1,767
    Mike Hewson
    Jan 7, 2005
  5. shapper
    Replies:
    2
    Views:
    322
    shapper
    Nov 19, 2006
Loading...

Share This Page