远程服务器返回错误:(500)内部服务器错误 [英] The remote server returned an error: (500) Internal Server Error
问题描述
请提出更正VB代码的建议.
项目要求:通过Web服务与maximo进行通信以加载
数据,即将带有数据的请求xml发布到maximo并从
获取响应
maximo
通讯方式:与maximo通讯的VB.net代码
功能:VB代码应将受maximo支持的XML文件发布到
给定maximo Web服务URL.
问题:尝试实现以上
时引发异常以下错误
功能.请找到以下错误.
远程服务器返回错误:(500)内部服务器错误
用于通信的代码:
Please advice to correct the VB Code.
Project Requirement: Communicate with maximo through webservices to load
data i.e Post the request xml with data to maximo and get the response from
maximo
Mode of communication: VB.net code to communicate with maximo
Functionality: VB Code should post the maximo supported XML file to the
given maximo Web Services url.
Issue: Below Exception Error is thrown on trying to achieve the above
functionality .Please find below error.
The remote server returned an error: (500) Internal Server Error
Code used to communicate :
Imports System.IO
Imports System.Xml
Imports System.Net
Public Class MainClass
Shared Sub Main()
Dim url As String =
"http://122.166.7.149/meaweb/services/PMOASSETINTQRY"
Dim req As WebRequest = WebRequest.Create(url)
req.Credentials = CredentialCache.DefaultCredentials
req.Method = "POST"
req.ContentType = "text/xml"
'req.Headers.Add("MI_XMLPROTOCOLREQUEST", "MatrixRouteRequest")
'req.Headers.Add("MI_XMLPROTOCOLVERSION", "3.2")
Dim writer As New StreamWriter(req.GetRequestStream())
Dim reader As New StreamReader("C:\test.xml")
writer.Write(reader.ReadToEnd())
Console.WriteLine("Posted to remote server")
writer.Close()
reader.Close()
Dim response As WebResponse = req.GetResponse()
Dim responseXML As New XmlDocument
responseXML.Load(response.GetResponseStream())
Dim twriter As New XmlTextWriter("c:\myresponseVB23.xml",
System.Text.Encoding.UTF8)
responseXML.WriteTo(twriter)
twriter.Flush()
twriter.Close()
response.GetResponseStream().Close()
req.GetRequestStream().Close()
End Sub ' Main
End Class
推荐答案
尝试在代码周围添加一个try..catch
块并捕获一个System.Exception
类型.使用调试器研究异常,包括所有内部异常,以了解服务器端出了什么问题.
Try adding atry..catch
block around your code and catching aSystem.Exception
type. Using the debugger investigate the exception including all inner exceptions to get the idea what went wrong at server side.
hi frnd,
您是否在中等信任环境下托管了您的网站?
如果您使用中等信任度,则请更改您的信任度,
与信任级别相关的web.config更改.
hi frnd ,
did you host you site on medium trust environmental?
if you use medium trust then please change you trust level,
changes into your web.config related to trust level.
<system.web><trust level="Full" /> ...</system.web>
希望对您有所帮助.
Hope it will help..
这篇关于远程服务器返回错误:(500)内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!