.NET Forum / Languages / C# / July 2007
Parameters xmldata, $filestream and $filedata are all missing error
|
|
Thread rating:  |
honguin@googlemail.com - 11 Jul 2007 09:45 GMT Hi,
With the following code, I have created a web request to a url which I am making a HTML POST with the html page request.htm, even though it makes a HTML POST, the StreamReader produces a XML response error shown after the code, with the description "Parameters xmldata, $filestream and $filedata are all missing. One of these must not be null."
Any suggestions in how to resolve this error?
Many thanks,
Hon
WebRequest request = WebRequest.Create("********************"); NetworkCredential networkCredential; string username = "*****", password = "*********";
private string sendRequestToCOLT() { try { // create reader and open file. StreamReader re = File.OpenText(@"request.htm");
// read a lines of text string text = "", input = null; while ((input = re.ReadLine()) != null) { input = input + "\n"; text = text + input; } byte[] byteArray = Encoding.UTF8.GetBytes(text); networkCredential = new NetworkCredential(username, password); request.Credentials = networkCredential; request.Method = "POST"; request.ContentLength = byteArray.Length; request.ContentType = "application/x-www-form- urlencoded"; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string result = reader.ReadToEnd(); response.Close(); return result;; } catch (Exception e) { messageTextBox.Text = "EXCEPTION ERROR: " + e.Message.ToString(); return null; } }
---------------------------------------------------------------------------------------------------------------------------------------------------------
<xml version="1.0"?>
<Acknowledgement>
<versionOfXmlSchema>1.0</versionOfXmlSchema>
<receiverSystem>B2BGateway</receiverSystem>
<receiverId>B2BGateway</receiverId>
<receiveTime>20070710-16:08:32</receiveTime>
<senderId>Unknown</senderId>
<senderTime>20070710-16:08:32</senderTime>
<dateMessage></dateMessage>
<message>
<messageType>B2BGateway</messageType>
<messageCode>-1</messageCode>
<messageDescription>com.wm.app.b2b.server.ServiceException: [ISS. 0086.9091] Parameters xmldata, $filestream and $filedata are all missing. One of these must not be null.
at pub.xml.xmlStringToXMLNode(xml.java:523)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 60)
at java.lang.reflect.Method.invoke(Method.java:391)
at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java: 322)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java: 612)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java: 44)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java: 235)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java: 49)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:198)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java: 39)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java: 411)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java: 521)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java: 369)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:246)
at com.wm.app.b2b.server.BaseService.invoke(BaseService.java: 168)
at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:324)
at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:581)
at com.wm.lang.flow.FlowState.step(FlowState.java:438)
at com.wm.lang.flow.FlowState.invoke(FlowState.java:403)
at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java: 982)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java: 612)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java: 44)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java: 235)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java: 49)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:198)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java: 39)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java: 411)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java: 521)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java: 369)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:246)
at com.wm.app.b2b.server.comm.DefaultServerRequestHandler.handleMessage(DefaultServerRequestHandler.java: 129)
at com.wm.app.b2b.server.comm.DefaultSocketRequestHandler.handleMessage(DefaultSocketRequestHandler.java: 181)
at com.wm.util.comm.Connection.handleMessage(Connection.java: 136)
at com.wm.util.comm.Connection$PollRunner.run(Connection.java: 465)
at com.wm.util.pool.PooledThread.run(PooledThread.java:105)
at java.lang.Thread.run(Thread.java:832)
</messageDescription>
</message>
</Acknowledgement>
Marc Gravell - 11 Jul 2007 10:36 GMT OK; you read a local file "request.htm" into a string, making sure line-breaks are \n [note - StringBuilder would have been more efficient here...]
You then get the UTF8 binary for this string, and upload this as the POST, with content-type " "application/x-www-form-urlencoded"
So: does "request.htm" actually contain form-encoded data? Based on the name, I'm guessing not... HTML is not the same thing. HTML is a markup language used to display data in a browser - very different to a HTTP POST, which is used to form a request (note that "HTML POST" doesn't really make sense except in the context "upload an HTML file by POSTing over HTTP"). You can use sniffers (such as Fiddler) to see what this POST should look like - or simply google. But it essentially boils down to name/value pairs, not HTML.
Additionally, note that WebClient is often much easier to use for uploads that WebRequest.
Marc
honguin@googlemail.com - 11 Jul 2007 11:03 GMT Hi,
"request.htm" is not a form-encoded data, what happens is that this page contains xml data in a text field, that when you hit the submit button, it contains a HTTP POST to a url, which in turn you receive an XML response. But it is not the XML response that I would like.
I placed even a string like "<HTML></HTML>" replacing the variable text in byte[] byteArray = Encoding.UTF8.GetBytes(text);, and it still receives the same error. Essentially the url is using a web service which only receives HTTP POSTs. I will have a look at the sniffer fiddler to see what it is doing
Hon.
> OK; you read a local file "request.htm" into a string, making sure > line-breaks are \n [note - StringBuilder would have been more [quoted text clipped - 16 lines] > > Marc Marc Gravell - 11 Jul 2007 11:26 GMT I don't think you fully understand the difference between HTML and HTTP. I described what your code does ("works as coded"). If "request.htm" is not form-encoded data, then don't send it as form-encoded data! An HTTP query does not generally expect to recieve HTML, and is not going to click any submit button. Rather, *when the HTML is loaded in a browser*, clicking the submit button causes a separate HTTP POST (var=value etc from the submitted form) which returns something (xml apparently).
The only time you would generally upload raw HTML is in a content-management system (or perhaps a forum / e-mail app with HTML editors).
Marc
honguin@googlemail.com - 11 Jul 2007 11:47 GMT Hi again,
How would you make a seperate HTTP Post to the url with only the XML data?
>From what you had said, you can only submit the data using the submit button via a form, can you perform something like as an "automation" in .NET?
Cheers,
Hon
> I don't think you fully understand the difference between HTML and > HTTP. I described what your code does ("works as coded"). If [quoted text clipped - 10 lines] > > Marc honguin@googlemail.com - 11 Jul 2007 11:56 GMT It seems to be a post over SSL.
The data sent represents a SSLv3-compatible ClientHello handshake. For your convenience, the data is extracted below.
Major Version: 3 Minor Version: 1 Random: 46 94 B6 83 DC B6 B3 7E 26 7C 82 04 32 69 35 4E D0 E4 BF 03 5F AC DD 03 1C C4 64 EF 15 77 69 8E SessionID: B2 69 E2 99 24 84 EA E8 5C D4 4B B9 CA 81 98 14 3E 8B 84 D0 FC 9D 87 16 BA FA F3 24 A8 C0 42 7D Ciphers: [0004] SSL_RSA_WITH_RC4_128_MD5 [0005] SSL_RSA_WITH_RC4_128_SHA [000A] SSL_RSA_WITH_3DES_EDE_SHA [0009] SSL_RSA_WITH_DES_SHA [0064] TLS_RSA_EXPORT1024_WITH_RC4_56_SHA [0062] TLS_RSA_EXPORT1024_WITH_DES_SHA [0003] SSL_RSA_EXPORT_WITH_RC4_40_MD5 [0006] SSL_RSA_EXPORT_WITH_RC2_40_MD5 [0013] SSL_DHE_DSS_WITH_3DES_EDE_SHA [0012] SSL_DHE_DSS_WITH_DES_SHA [0063] TLS_DHE_DSS_EXPORT1024_WITH_DES_SHA
On Jul 11, 11:47 am, "hong...@googlemail.com" <hong...@googlemail.com> wrote:
> Hi again, > [quoted text clipped - 24 lines] > > - Show quoted text - Marc Gravell - 11 Jul 2007 12:08 GMT SSL chains are deliberately impenetrable. Fiddler will manage, but only from IE - hence looking at what you get when using the browser is probably a better starting point.
Regards creating an HTTP post of xml... how about:
string request = @"<xml/>", response; using (WebClient client = new WebClient()) { response = client.UploadString(url, "POST", request); }
Marc
honguin@googlemail.com - 11 Jul 2007 12:15 GMT Ok, I give you the lowdown on this: -
I made used the web page on the web browser and hit the submit with Fiddler 2 running, and it gave: -
In the request header, Content-Type: application/x-www-form-urlencoded Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/ vnd.ms-powerpoint, application/msword, */* Accept-Language: en-gb
Hon.
> SSL chains are deliberately impenetrable. Fiddler will manage, but > only from IE - hence looking at what you get when using the browser is [quoted text clipped - 8 lines] > > Marc honguin@googlemail.com - 11 Jul 2007 12:31 GMT Looking at the html page in the source code, it starts with : - <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
<head> <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> <meta name=ProgId content=Word.Document> <meta name=Generator content="Microsoft Word 10"> <meta name=Originator content="Microsoft Word 10"> <link rel=File-List href="CLI%20-%20Reseller%20Operations%20Support%20System_files/ filelist.xml"> <link rel=Edit-Time-Data href="CLI%20-%20Reseller%20Operations%20Support%20System_files/ editdata.mso"> <!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]-->
Regards,
Hon
On Jul 11, 12:15 pm, "hong...@googlemail.com" <hong...@googlemail.com> wrote:
> Ok, I give you the lowdown on this: - > [quoted text clipped - 24 lines] > > - Show quoted text - Marc Gravell - 11 Jul 2007 12:47 GMT Gotta love Word. However, the extract doesn't include any of the FORM stuff, so I'm not sure anybody can diagnose anything from this.
Marc
Marc Gravell - 11 Jul 2007 12:48 GMT No actual body? Depending on which version of Fiddler you are using you may need to switch tabs, double-click, etc to see the body.
Marc
honguin@googlemail.com - 11 Jul 2007 13:16 GMT When I was testing the urls, I stumbled upon this: -
Typing in the url https://www.wmdmzis12.colt.net/invoke/RossB2BGateway.online.http/submitCLICPSOrder threw the error as seen before.
But then I tried the url https://www.wmdmzis12.colt.net/invoke/RossB2BGateway.online.http/submitCLICPSOrd er?xmldata="" and it displayed something which is closer to the solution.
<?xml version="1.0" ?> - <Acknowledgement> <versionOfXmlSchema>1.0</versionOfXmlSchema> <receiverSystem>B2BGateway</receiverSystem> <receiverId>B2BGateway</receiverId> <receiveTime>20070711-13:50:38</receiveTime> <senderId>Unknown</senderId> <senderTime>20070711-13:50:38</senderTime> <dateMessage /> - <message> <messageType>B2BGateway</messageType> <messageCode>-1</messageCode> <messageDescription>/ is invalid. The value doesnt match the pattern.</messageDescription> </message> </Acknowledgement>
By the looks of it, if i submit the whole xml data as a string within the "", in theory, the response xml packet should be a valid request to the web service.
Now I tried placing the "xmldata=" + someMethodDisplayingTheXMLRequestString() subsitiuting text in the statement byte[] byteArray = Encoding.UTF8.GetBytes(text);
But that doesn't seem to be working, but is there a way that you can make a HTTP request with the xmldata parameter string and the xml data shoved at the end of the ? query.
Cheers,
Hon
> No actual body? Depending on which version of Fiddler you are using > you may need to switch tabs, double-click, etc to see the body. > > Marc Marc Gravell - 11 Jul 2007 13:27 GMT Yes and no - you would probably need to url-encode the entire string, but more importantly watch out: url strings can be limited in length. You could run into problems where you lose the end of your fragment.
But the short answer is that (as with any such service) you really need to know what the API is... is there no documentation? ideally with an example?
Marc
honguin@googlemail.com - 11 Jul 2007 16:40 GMT Hi,
I sorted out the problem now adding the whole xml string at the end of the url which worked fine (no url strings limitation in length). I adopted a HTTPWebRequest and StreamReader.
Cheers,
Hon
> Yes and no - you would probably need to url-encode the entire string, > but more importantly watch out: url strings can be limited in length. [quoted text clipped - 5 lines] > > Marc honguin@googlemail.com - 11 Jul 2007 16:42 GMT Yep, there is API documentation on this which shows some examples but there isn't much on what the typical XML requests are.
On Jul 11, 4:40 pm, "hong...@googlemail.com" <hong...@googlemail.com> wrote:
> Hi, > [quoted text clipped - 17 lines] > > - Show quoted text - honguin@googlemail.com - 11 Jul 2007 11:24 GMT Hi,
Fiddler didn't display any useful information in the case of the connection to the url from my code only in that a connection was established.
Hon.
> OK; you read a local file "request.htm" into a string, making sure > line-breaks are \n [note - StringBuilder would have been more [quoted text clipped - 16 lines] > > Marc Marc Gravell - 11 Jul 2007 11:36 GMT I'd be more interested in what fiddler outputs when you use the web-page directly, i.e. through a browser clicking on the button. This will then tell you immediately what you are meant to be uploading. If the post is over SSL you will need fiddler 2 (or alternatively the debug version of some MS dlls).
Marc
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|