Mar 9, 2011
I'm getting an exception when trying to access an .asmx webservice within a MVC site. I've tried numerous things like updating the web reference within the console application and building another quick app to test, but can't get passed this issue. If I pull the URL out of the svc variable, I can browse to it directly.
Exception Details
System.Web.Services.Protocols.SoapException
occurred Message=Server was unable
to process request. ---> Value cannot
be null. Parameter name: uriString
Source=System.Web.Services Actor=""
Lang="" Node="" Role=""
StackTrace:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream
responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at ClarityIntegration.SendTrackerDataToClarity()
in [REDACTED].Reference.cs:line 78
at [REDACTED].Program.Main(String[] args)
in [REDACTED].Program.cs:line 33
InnerException:
CONSOLE APP CODE
var svc = new TrackerClarityService.ClarityIntegration()
{
Url = url,
Credentials =
new System.Net.NetworkCredential("user", "pass", "domain")
};
svc.SendTrackerDataToClarity();
svc.Dispose();
The exception was coming out of the Web Service itself. There were some global variables not being initialized directly through the .asmx call that were being initialized by the application itself.
Some simple checks on variables within the Web Service and setting what needs to be set have fixed up the issue.
View 2 Replies
Mar 25, 2010
I have a dynamic catalogue, where customers select products they are interested in. The manager of the company I am doing this for would like to be able to create an up to date offline catalogue at any given time, to send out to customers who dont have an internet connection. So far its going really well. I am using Server.Execute to get the content for each page, then putting it in static html pages and changing the dynamic links to static html links (ie changing all aspx links to htm). I am able to output all the pages for about us, contact us, home, and the entire catalogue. However, one of the stylesheets which is included in the page based on the URL (if the page is in the administration section then it is not included, otherwise it is) is not being included in the pages when it should be. I have tried outputting the URL but it just returns the URL of the calling page, not the page being called.
View 1 Replies
Jan 21, 2010
I there a way to know if a request is a soap request on AuthenticateRequest event for HttpApplication? Checking ServerVariables["HTTP_SOAPACTION"] seems to not be working all the time.
public void Init(HttpApplication context) {
context.AuthenticateRequest += new EventHandler(AuthenticateRequest);
}
protected void AuthenticateRequest(object sender, EventArgs e) {
app = sender as HttpApplication;
if (app.Request.ServerVariables["HTTP_SOAPACTION"] != null) {
// a few requests do not enter here, but my webservice class still executing
// ...
}
}
I have disabled HTTP POST and HTTP GET for webservices in my web.config file.
<webServices>
<protocols>
<remove name="HttpGet" />
<remove name="HttpPost" />
<add name="AnyHttpSoap" />
</protocols>
</webServices>
Looking at ContentType for soap+xml only partially solves my problem. For example,
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 1131
Content-Type: text/xml
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: ro
Host: localhost
mymethod: urn:[URL]
Some clients instead of having the standard header SOAPAction: [URL], have someting like in example above. "mymethod" represents the method in my web service class with [WebMethod] attribute on it and [URL] is the namespace of the webservice. Still the service works perfectly normal. The consumers use different frameworks (NuSOAP from PHP, .NET, Java, etc).
View 4 Replies
Oct 24, 2010
I develop an asmx web service (i.e. ASP.NET 2.0). There's a piece of code that may read the contents of the HTTP request (via HttpContext.Current.Request.InputStream) while processing it. I realise that InputStream may only be read once for a request, and I make sure I never try to read it more than once.
The problem seems to be that if InputStream happens to be read during the early stages of the application's lifecycle (e.g. after pskill w3wp, during Application_Start), the HTTP request fails with a HTTP 400 - Bad Request error, with no explanation given, no exception thrown and no entry in the httperr log. If it is read later (e.g. within the web method itself), requests run fine whether InputStream is read or not. Application_Start runs fine if InputStream isn't read.
Is this some sort of ASP.NET bug? IIS bug? Or am I doing something wrong by daring to read InputStream? And if so, is there another way to get a look at the "raw" contents of the request without disturbing the inner workings of IIS/ASP.NET? In short, adding this code within Application_Start is enough to reproduce this error: using (StreamReader reader = new StreamReader(HttpContext.Current.Request.InputStream))reader.ReadToEnd();
View 1 Replies
Apr 4, 2011
I am trying to use curl to access 3rd party webservice, I used the following code which works well if I try it on my own linux server, the data is being sent ok, but the IIS on the 3rd party server returns an error.
$longdata is a long string of data, maybe over 1000 characters long the 3rd party has many working clients with various implementations so the problem is on my side. what do I need to add to the request in order to get this through ?
<?php
$c = curl_init();
// curl_setopt($c, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($c, CURLOPT_URL, 'http://XXX.com/test/index.asmx');
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$post = array('param1' => 'XXXX', "param2" => "Y", "Param3" => $long_data);
curl_setopt($c, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($c);
echo $response;
/*
Response:
HTTP/1.1 100 Continue
HTTP/1.1 500 Internal Server Error
Date: Tue, 05 Apr 2011 14:11:51 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 100
Request format is invalid: multipart/form-data; boundary=----------------------------5d738237d9e0.
*/
?>
View 2 Replies
Dec 23, 2010
I created a WCF. The web.config is as follows,
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
The following can be seen in the service.svc file,
class AppServiceHostFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
return new WebServiceHost2(serviceType, true, baseAddresses);
}
}
This is the method in the service.svc.cs,
[WebHelp(Comment="Sample description for GetData")]
[WebGet(UriTemplate="/GetData/param1/{i}/param2/{s}")]
[OperationContract]
public SampleResponseBody GetData(string i, string s)
{
// TODO: Change the sample implementation here
// if (i < 0) throw new WebProtocolException(HttpStatusCode.BadRequest, "param1 cannot be negative", null);
return new SampleResponseBody()
{
Value = String.Format("Sample GetData response: '{0}', '{1}'", i, s)
};
}
The following is the webservice url. It returns data if it's run through the asp.net engine but throws bad request when run from IIS. I added the following entry in the web.config but no use. it still fails.
<httpRuntime maxRequestLength="1500000" executionTimeout="180"/>
[URL]-499,500~~~/param2/621100,621600,622100,611500,611600,611700,561300,611100,611200,611300,611400,622200,622300,623100,621100,621600,622100,611500,611600,611700,561300,611100,611200,611300,611400,622200,622300,623100,621100,621600,622100,611500,611600,611700,561300,611100,611200,611300,611400,622200,622300,623100,,622100,611500,611600,611700,561300,611100,611200,611300,611400,622200,622300,623100,611100,611200,611300,611400,622200,622300,623100,611100,611200,611300,611400,622200,622300,623100,611100,611200,611300,611400,622200,622300,623100,623100,611100,611200,611300,611400,622200,622300,623100,623100,611100,611200,611300,611400,622200,622300,623100,622300,623100,623100,611100,611200,611300,611400,622200,622300,623100,622300,623100,623100,611100,611200,611300,611400,622200,622300,623100,623100,623100,611100,611200,611300,611400,622200,622300,623100,623100,623100,611100,611200,611300,611400,622200,622300,623100,623100,623100,611100,611200,611300,611400,622200,622300,623100
View 2 Replies