2013-01-18 87 views
1

男人我正在一個api上,我必須發送請求到服務器xml基於肥皂請求,但服務器顯示我以下錯誤:遠程服務器返回錯誤:(500)內部服務器錯誤,幫助將大幅升值遠程服務器返回一個錯誤:(500)httprequest上的內部服務器錯誤

我的代碼是這樣的:

Dim s = "" 
    s = s & "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf 

    s = s & "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">" & vbCrLf 

    s = s & "<soapenv:Body>" & vbCrLf 

    s = s & "<OTA_AirLowFareSearchRQ EchoToken=""0"" SequenceNmbr=""0"" TransactionIdentifier=""0"" AvailableFlightsOnly="""" DirectFlightsOnly="""" xmlns=""http://www.opentravel.org/OTA/2003/05"">" & vbCrLf 
    s = s & "<POS xmlns=""http://www.opentravel.org/OTA/2003/05"">" & vbCrLf 
    s = s & "<Source AgentSine="""" PseudoCityCode="""" TerminalID=""1"">" & vbCrLf 
    s = s & "<RequestorID ID=""AFFILIATE""/>" & vbCrLf 
    s = s & "</Source>" & vbCrLf 



    s = s & "<YatraRequests>" & vbCrLf 
    s = s & "<YatraRequest DoNotHitCache=""false"" DoNotCache=""false"" YatraRequestTypeCode=""SMPA"" Description="""" MidOfficeAgentID=""28737"" AffiliateID=""TRAVELPARTNER"" />" & vbCrLf 
    s = s & "</YatraRequests>" & vbCrLf 
    s = s & "</POS>" & vbCrLf 
    s = s & "<TravelerInfoSummary>" & vbCrLf 
    s = s & "<AirTravelerAvail>" & vbCrLf 
    s = s & "<PassengerTypeQuantity Code=""ADT"" Quantity=""" & drAdult.SelectedValue & """/>" & vbCrLf 
    s = s & "<PassengerTypeQuantity Code=""CHD"" Quantity=""" & drpChil.SelectedValue & """/>" & vbCrLf 
    s = s & "<PassengerTypeQuantity Code=""INF"" Quantity=""" & drpInfant.SelectedValue & """/>" & vbCrLf 

    s = s & "</AirTravelerAvail>" & vbCrLf 
    s = s & "</TravelerInfoSummary>" & vbCrLf 
    s = s & "<SpecificFlightInfo>" & vbCrLf 
    s = s & "<Airline Code=""""/>" & vbCrLf 
    s = s & "</SpecificFlightInfo>" & vbCrLf 
    s = s & "<OriginDestinationInformation>" & vbCrLf 
    s = s & "<DepartureDateTime>" & txtDeparture.Text & "</DepartureDateTime>" & vbCrLf 
    s = s & "<OriginLocation CodeContext=""IATA"" LocationCode=""" & drpFrom.SelectedValue & """>" & drpFrom.SelectedValue & "</OriginLocation>" & vbCrLf 
    s = s & "<DestinationLocation CodeContext=""IATA"" LocationCode=""" & drpTo.SelectedValue & """>" & drpTo.SelectedValue & "</DestinationLocation>" & vbCrLf 
    s = s & "</OriginDestinationInformation>" & vbCrLf 
    s = s & "<TravelPreferences>" & vbCrLf 
    s = s & "<VendorPref Code=""SG""/>" & vbCrLf 
    s = s & "<VendorPref Code=""DN""/>" & vbCrLf 
    s = s & "<CabinPref Cabin=""" & drpClass.SelectedValue & """/>" & vbCrLf 
    s = s & "</TravelPreferences>" & vbCrLf 
    s = s & "</OTA_AirLowFareSearchRQ>" & vbCrLf 
    s = s & "</soapenv:Body>" & vbCrLf 
    s = s & "</soapenv:Envelope>" & vbCrLf 

    Dim url = "http://203.189.91.127:9090/services/spm/spm" 

    Dim doc As New XmlDocument() 

    doc.LoadXml(s) 

    Dim req As HttpWebRequest = WebRequest.Create(url) 
    req.Headers.Add("SOAPAction", "") 

    req.ContentType = "text/xml;charset=""utf-8""" 
    req.Accept = "text/xml" 
    req.Method = "POST" 
    Dim stm As Stream = req.GetRequestStream() 
    doc.Save(stm) 
    stm.Close() 
    Dim resp As WebResponse = req.GetResponse() 
    stm = resp.GetResponseStream() 
    Dim r As StreamReader = New StreamReader(stm) 
    'process SOAP return doc here. For now, we'll just send the XML out to the browser ... 
    Response.Write(r.ReadToEnd()) 
+0

作爲答案編輯如下,500意味着代碼中存在一個錯誤。如果您的請求以某種方式無效,那麼SOAP服務器應該使用SOAP錯誤消息進行響應。現在並不是說你的請求中沒有任何東西觸發了他們身邊的錯誤.... –

回答

1

HTTP錯誤代碼500,因爲它說,是內部服務器錯誤。您的聯繫人可能需要查看他的日誌,並報告錯誤對您來說是什麼,因爲它是在他的最後,而不是你的。

如果您的請求格式不符合他的預期格式,並拋出它需要對他的最終妥善處理報告錯誤500

所以不是錯誤....基本上它出來的機會,你的手中。

0

評論第一這個事情

的=?XML版本= 「」 1.0 「」 編碼= 「」 UTF-8 「」?」

然後添加以下代碼工作罰款我嘗試

​​

感謝

Umaji Mogre

相關問題