.NET Web Service
Apache HttpClient
Problem:
When I tried to call the service as follows from my JUnit Test
HttpPost post = new HttpPost("http://localhost:1287/service.asmx/SubmitZip");
post.addHeader("Content-Type", "application/x-www-form-urlencoded");
post.addHeader("Content-Type", "application/x-www-form-urlencoded");
MultipartEntity entity = new MultipartEntity();
entity.addPart("b64zip", new StringBody(new String(Base64.encodeBase64(IOUtils.toByteArray(submissionStream)))));
post.setEntity(entity);
I got this error:
System.InvalidOperationException: Missing parameter: b64zip.
at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
Solution:
To fix it, I needed to call it as follows:
List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>(1);
To fix it, I needed to call it as follows:
List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("b64zip", new String(Base64.encodeBase64(IOUtils.toByteArray(submissionStream)))));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Answer: It was because ASP.NET State Server was turned off.
ReplyDelete