G
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>[email protected]</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>[email protected]</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();
//}
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>[email protected]</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>[email protected]</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();
//}