问题描述
请提出更正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
推荐答案
<system.web><trust level="Full" /> ...</system.web>
希望对您有所帮助.
Hope it will help..
这篇关于远程服务器返回错误:(500)内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!