WCF service is throwing requested url was reject error - asp.net

I have a WCF service hosted in IIS. It is for file upload. For large files (4 MB) WCF returns error "Requested url was reject . Please contact admin."
It works for smaller files. Same service is working on different server for large files too. I compared IIS setting between these two servers and everything looks same.
Any suggestion?

This error appears to be a custom error, not an actual error message. If it is an error caused by uploading a too large file, I think it may be a problem with the server configuration. In my experience, you need to include the following configuration.
<bindings>
<basicHttpsBinding>
<binding name="mybinding" maxReceivedMessageSize="2147483647">
</binding>
</basicHttpsBinding>
</bindings>
Then apply it in the particular service endpoint.
<services>
<service name="WcfService1.Service1">
<endpoint bindingConfiguration="mybinding" address="" binding="basicHttpBinding" contract="WcfService1.IService1"></endpoint>
</service>
</services>
At last, I would like to know the practical error if the problem still exists. Feel free to let me know if there is anything I can help with.

Related

Setting up a WCF host within a website project

This is going to be a weird question, but:
I'm currently running a wcf service on my website (made in Visual Studio 2012 - .scv file). I have a console client which I try to test the connection with in addition to the built in wcf test client. The test client runs fine and I'm able to call upon the functions, but when I stop running the site/test client (which should mean host by extension, right?), my console client can still run and talk to the service just fine.
I'm also able to visit the WCF service page while it's not running in the browser. When I created the WCF in console, I was not able to do any of these things while the host wasn't actually running. Because of this I'm wondering if there's something wrong with the code that I'm just not seeing.
I could see this developing into an issue when I try to get the website online on a server (since my testing client won't be located on the same machine as the service. I'm assuming this is happening because I have access to the files even when it's not running).
What should I do/what is wrong?
Thank you for your time.
relevant web.config code:
<system.serviceModel>
<services>
<!-- ICanHasGamez=solution that holds the webpage&wcfservice -->
<service name="ICanHasGamez.APIHost" behaviorConfiguration="behavior">
<endpoint address="" binding="basicHttpBinding" contract="ICanHasGamez.IAPIHost">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name ="behavior">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
app.config code from the Console Client:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAPIHost" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2105/APIHost.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IAPIHost" contract="ServiceReference1.IAPIHost"
name="BasicHttpBinding_IAPIHost" />
</client>
</system.serviceModel>
</configuration>
In your website project's properties under the web tab, are you hosting it in IIS? If so, the WCF service will keep running, even if you're not using the built in WCF test client. IIS runs on its own, outside of the visual studio environment. You can turn off your service by stopping it in IIS manager, if you'd like, but otherwise it's usable outside of VS.
In contrast, running the WCF service in a console (known as self-hosted) will close down when it's host application, i.e your console application, closes.
In short, if you are using local IIS for your web project, then this isn't anything you've done wrong and is expected behaviour. And regarding running your service on a different machine to your test client, that's not a problem. If you're running it in IIS, then your hosting computer just needs IIS turned on and that project running in IIS there. Voila! If you're running the service as self-hosted, i.e in a console, just leave the console open. Check out this StackOverflow question for some of the pros and cons of self-hosted wcf vs IIS (the accepted answer is a bit local to that particular OP, but the answers below are more informative).
I hope this helps and I hope I'm not barking up the wrong tree here.
I don't see anything wrong with the scenario you described - its expected behavior.
When you host the WCF service in IIS, as long as IIS is up and running (and there's no other problems), your service can receive requests. If the service host has been disposed (due to inactivity timeout or other reasons), if a new request is received IIS will spin up a new instance.
On the other hand, if you're self-hosting the WCF service in, for example, a console app, then the only time that service is able to respond to requests is when the self-hosting application is running.
So to answer your question, you're not doing anything wrong, and you don't need to do anything different. You should be able to simply deploy the WCF Service to the remote server, and then access it with your client.

Forming an HTTP request for a SOAP web service

I trying to acces this SOAP Web Service (http://iberius.scjn.gob.mx:8080/Mobile/Tematica.svc) and I also have its WSDL files available
http://iberius.scjn.gob.mx:8080/Mobile/Tematica.svc?wsdl
http://iberius.scjn.gob.mx:8080/Mobile/Tematica.svc?wsdl=wsdl0
http://iberius.scjn.gob.mx:8080/Mobile/Tematica.svc?xsd=xsd0
http://iberius.scjn.gob.mx:8080/Mobile/Tematica.svc?xsd=xsd1
http://iberius.scjn.gob.mx:8080/Mobile/Tematica.svc?xsd=xsd2
http://iberius.scjn.gob.mx:8080/Mobile/Tematica.svc?xsd=xsd3
But I'm never worked with soap and I'm not finding the WSDL files clear enough.
What I'm trying to do is query the service for the different operations available, for example the ListaMinistros operation that takes a parameter actualizacion that is a date in the format yyyymmdd.
I have tried every possible combination to contact the service but it responds with a Endpoint not found response.
If you could provide me with an example of the SOAP XML it would be great as almost all of the other available operations are the same so I cold see how to do it myself.
Thanks in advance
========
EDIT
I have set up the WSDL reference in a C# project with visual studio to se what kind of request it makes
the config file it comes up with its the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="Rest">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint
binding="customBinding" bindingConfiguration="Rest" contract="SCJN.Tematica"
name="Rest" />
</client>
</system.serviceModel>
But it doesent includes the address for the endpoint, so I modified the endpoint to look like this:
<endpoint address="http://iberius.scjn.gob.mx:8080/Mobile/Tematica.svc"
binding="customBinding" bindingConfiguration="Rest" contract="SCJN.Tematica"
name="Rest" />
But the service responds with a endpoint not found.
So is there a way to find out wich address to call.
Also the WSDL does not list SOAPAction attributes but rather wsaw:Action in the operations supported, wich is translated in my .NET code to the following
[System.ServiceModel.OperationContractAttribute(Action="urn:Tematica/ListaMinistros", ReplyAction="urn:Tematica/ListaMinistrosResponse")]
ConsoleApplication2.SCJN.Ministro[] ListaMinistros(string actualizacion);
Try soapUI.org, it's a feature rich opensource/commercial web service explorer. You can feed in the WSDL and it will automatically create SOAP request stubs, which can be send to the endpoints named in the WSDL. Even the HTTP headers can be made visible.
You can download webservice studio.
Its free program and it will show you a soap message. Search in the google.
These articles [1][2] describes wsdl and soap.
The better options is to use the wsdl2java tool available with the platform. If there is no such thing available then you can use some other framework like Axis2 and examine the request and response messages for each and every operation.
[1] http://wso2.org/library/2873
[2] http://wso2.org/library/2935

There was no endpoint listening and Error 404

We have deployed a web service on a production server and still getting this error once trying to get a call to it :
"There was no endpoint listening at http://www.ourproductionserver.com/ClientService.svc/mex that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details."
When looking into the InnerException, it return us a 404 File Not Found...
Weird part, is that if we copy/past the exact same url as giving in the error below (http://www.ourproductionserver.com/ClientService.svc) in IE or FireFox, it shows correctly. Heum, what do we do wrong?
We've also tried it on a local server and everything works fine.
Anyone alrealy get something similar and how to resolve it?
Note : Sorry for my english, I usualy talk french.
Our webconfig :
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding name="WebBinding"></binding>
</webHttpBinding>
</bindings>
<services>
<service name="ourLib.ServiceImplementations.ClientActionService" behaviorConfiguration="ServiceBehavior">
<endpoint name="WebEndpoint" behaviorConfiguration="EndpointBehavior" address="" binding="webHttpBinding"
contract="ourLib.ServiceContracts.IClientActionService">
</endpoint>
<endpoint contract="ourLib.ServiceContracts.IClientActionService" address="mex" binding="mexHttpBinding"></endpoint>
</service>
<system.serviceModel>
Our ClientService.svc
<%# ServiceHost Language="C#" Debug="true" Service="ourLib.ServiceImplementations.ClientActionService" %>
UPDATE
We discover that the ISP is set to medium trust level when we are set to Full trust. Can it change something? If yes, how could we change it other than web.config (which we alrealy tried).
What is "/mex"? Is that a function within your service class? I just tested on my own Webservice.svc and wasn't able to do / so I'm not sure you can actually do that...
If you are trying to get a client to connect to your service, you should be able to just use the .svc URL and then invoke a function on the .NET-generated client object.
It looks like you're trying to make a call out to the metadata exchange endpoint (mex) which is only used when generating the metadata (the WSDL) in the first place. I would suggest checking where you set the service url and making sure you don't have the mex part on the end.
Well neither of us or the ISP find the reason why so instead of talking to the webservice to gain access to the DB, they've put a public IP Address so we can access to the Database directly via this IP instead of goin through a webservice.
Thanks you all but I would love to find out why in case this happen another time in the futur ...

WCF Endpoints & Binding Configuration Issues

I am running into a very strange issue here folks. For simplicity I created a project for the sole purpose of testing the issue outside the framework of a larger application and still encountered what is either a bug in WCF within Visual Studio 2010 or something related to my WCF newbie skill set : )
Here is the issue:
I have a WCF endpoint I created running inside of an MVC3 project called "SimpleMethod". The method runs inside of a .svc file on the root of the application and it returns a bool.
Using the "WCF Service Configuration Editor" I have added the endpoint to my Web.Config along with a called "LargeImageBinding".
Here is the service:
[OperationContract]
public bool SimpleMethod()
{
return true;
}
And the Web.Config generated by the Config Tool:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="LargeImageBinding" closeTimeout="00:10:00" />
</wsHttpBinding>
</bindings>
<services>
<service name="WCFEndpoints.ServiceTestOne">
<endpoint address="/ServiceTestOne.svc" binding="wsHttpBinding"
bindingConfiguration="LargeImageBinding" contract="WCFEndpoints.IServiceTestOne" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
The service renders fine and you can see the endpoint when you navigate to: http://localhost:57364/ServiceTestOne.svc - Now the issue occurs when I create a separate project to consume the service. I add a service reference to a running instance of the above project, point it to: http://localhost:57364/ServiceTestOne.svc
Here is the weird part. The service automatically generates just fine but In the Web.Config the endpoint that is generated looks like this:
<client>
<endpoint address="http://localhost:57364/ServiceTestOne.svc/ServiceTestOne.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServiceTestOne"
contract="ServiceTestOne.IServiceTestOne" name="WSHttpBinding_IServiceTestOne">
As you can see it lists the "ServiceTestOne.svc" portion of the address twice!
When I make a call to the the service I get the following error:
The remote server returned an error: (404) Not Found.
I tried removing the extra "/ServiceTestOne.svc" at the end of the endpoint address in the above config, and I get the same exact error.
Now what DOES work is if I go back to the WCF application and remove the custom endpoint and binding references in the Web.Config (everything in the "services" and "bindings" tags) then go back to the consumer application, update the reference to the service and make the call to SimpleMethod()....BOOM works like a charm and I get back a bool set to true.
The thing is, I need to make custom binding configurations in order to allow for access to the service outside of the defaults, and from what I can tell, any attempt to create custom bindings makes the endpoints seem to run fine, but fail when an actual method call is made.
Can anyone see any flaw in how I am putting this together? Thank you for your time - I have been running in circles with this for about a week!
When hosting a WCF service in IIS, the base address of the service is formed using the following format: {protocol}://{host}:{port}/{applicationName}/{svcFileName}. This is the address you can browse to get the WCF help page and/or the metadata (on a default configuration).
To form the actual address of the endpoint (the one your client needs to use), the following format is used: {serviceBaseAddress}/{endpointAddress}
Comparing the format above and the sample configuration you provided explains why you're getting ServiceTestOne.svc twice in your client address.
If you want the address of your service to be http://localhost:57364/ServiceTestOne.svc, I'd recommend leaving the address attribute empty in your endpoint configuration:
<endpoint address="" ... />

WCF Service support file jsdebug fails to load

I have a WCF service that gets called from client side JavaScript. The call fails with a Service is null JavaScript error. WebDevelopment helper trace shows that the calls to load the jsdebug support file results in a 404 (file not found) error.
Restarting IIS or clearing out the Temp ASP.Net files or setting batch="false" on the compilation tag in web.config does not resolve the problem
From the browser
https://Myserver/MyApp/Services/MyService.svc displays the service metadata
however
https://Myserver/MyApp/Services/MyService.svc/jsdebug results in a 404.
The issue seems to be with the https protocol. With http /jsdebug downloads the supporting JS file.
Any ideas?
TIA
Figured it out!
Here is the services configuration section from web.config
Look at the bindingConfiguration attribute on the endpoint. The value "webBinding" points to the binding name="webBinding" tag in the bindings and that is what tells the service to use Transport level security it HTTPS. In my case the attribute value was empty causing the webservice request to the /js or /jsdebug file over HTTPS to fail and throw a 404 error.
<services>
<service name="MyService">
<endpoint address="" behaviorConfiguration="MyServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Services.MyService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
Note that the bindingConfiguration attribute should be empty ("") if the service is accessed via http instead of https (when testing on local machine with no certs)
Hope this helps someone.
If you still get the same error after all your possible work done. Just add a "AJAX Enabled WCF-Service".
For me the issue was the following; we added MVC to a solution with routing. Our WCF services were not being ignored. I resolved this by adding the following rule (where "WCF" is the folder we keep our services in).
routes.IgnoreRoute("WCF/{*pathInfo}");
Hope that saves somebody a few hours.

Resources