不支持URI格式
我正在实施webservices API。我发送xml格式的请求,其中一些来自数据库的凭据和我的请求的响应我得到xml表单反馈。我正在使用SOMee服务器进行测试,当我运行我的程序时,我收到错误不支持URI格式。请帮我解决我的疑问。对于referenece,我正在粘贴我的代码。
I am implementing webservices API. I am sending request in xml form in which some credentials coming from database and on the response of my request I am getting xml form feedback. I am using SOMee server for testing when i am running my program i am getting an error "URI formats are not supported". Please help me to resolve my query. For referenece i am pasting my code.
if (oDataSet.Tables[0].Rows.Count > 0)
{
XmlWriter oXmlWriter = XmlWriter.Create("http://impertosolutions.somee.com//MobileAPI_XML//MobileBookingRequest.xml");
oXmlWriter.WriteStartDocument();
oXmlWriter.WriteStartElement("ReprintRequest");
oXmlWriter.WriteStartElement("UserTrackID");
oXmlWriter.WriteString(oDataSet.Tables[0].Rows[0]["OrderId"].ToString());
oXmlWriter.WriteEndElement();
oXmlWriter.WriteEndDocument();
oXmlWriter.Close();
XmlDocument oXmlDocument= new XmlDocument();
oXmlDocument.Load("http://impertosolutions.somee.com//MobileAPI_XML//MobileBookingRequest.xml");
StringWriter oStringWriter= new StringWriter();
XmlTextWriter oXmlTextWriter= new XmlTextWriter(oStringWriter);
oXmlDocument.WriteTo(oXmlTextWriter);
Response.ContentType="text/xml";
lstrInput = oXmlDocument.OuterXml;
lobjServ.REPRINT(lobjSec, lstrInput, ref lstrOutput, ref lstrError);
}
如果您的代码包含a href
然后uri确实无效。创建此问题时可能也会出错。在这种情况下,请编辑此问题并告诉我。然后我会删除这个答案。
If your code litteraly includes thea href
then the uri is indeed invalid. Might also be a mistake when creating this question. In that case please edit this question and let me know. I will then remove this answer.
oXmlDocument.Load("<a href="http://impertosolutions.somee.com//MobileAPI_XML//MobileBookingRequest.xml">http://impertosolutions.somee.com//MobileAPI_XML//MobileBookingRequest.xml</a>");
您不能简单地打开URL,就像这是一个本地文件。网络服务器根本不接受它。首先需要创建xml(文件),然后将其上传到URL。更改你的代码,使它将xml写入实际文件(例如:c:\ temp \ MobileBookingRequest.xml)
然后你完成并调用 xmlWriter.Close();
试试这个:
You cannot simply open an URL as if it was a local file. The webserver simply won't accept it. You first need to create the xml (file) and then upload it to the url. Change your code so it writes the xml to an actual file (for example: c:\temp\MobileBookingRequest.xml)
Then after you are done and called xmlWriter.Close();
try this:
WebClient client = new WebClient();
//client.Credentials = new NetworkCredential("username", "password");
client.UploadFile("http://impertosolutions.somee.com/MobileAPI_XML/MobileBookingRequest.xml", "c:\temp\MobileBookingRequest.xml");
祝你好运!
Good luck!