wcf AspNetCompatibilityRequirements - wcf

hi how to and where to use [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] in vb(wcf). Im writing it in my .svc file
but im not able to do.
giving me error

i figured it out
AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Required)> _

Related

WCF RIA services and WSDL generation

Need help on an issue I am having. I inherited this WCF RIA project and am trying to understand a couple of things.
When I publish the project, how does the WSDL get generated and put on the URL that I published to?
And I want to incorporate FaultException handling so as to transmit the exceptions to the client side. I read some stuff regarding the FaultException on the web and was able to get a small sample working with the regular WCF service.
I thought it would be similar within my actual project. But unfortunately I am running into some issues(probably due to my lack of WCF + RIA services knowledge).
So in my actual project my Context class derives off of LinqToEntitiesDomainService.
I created a new ContextFaultException class which had some methods to capture some custom error messaging.
Then I applied the [FaultContract(typeof(ContextFaultException))] to some of the methods in my Context class. Everything compiles and all is fine. But when I published to a website and then when I added this service reference to the client, I don't see my new ContextFaultException in the Reference.cs file that's generated.
I thought may be moving it within the Context class will solve the issue. So I made my ContextFaultException class as an inner class of this Context class but I am running into some other issues. Before I try to figure out these issues, I just want to know if this the right approach?
Any suggestions/pointers??
TIA
The URL must be formatted to get to the namespace wdsl
for example:
namespace My.Namespace.Services
{
[EnableClientAccess()]
public partial class MyClassName : LinqToEntitiesDomainService<XXX>
{
....
}
}
Then use the following pattern for the url
http://YOURHOST/APP/Services/My-Namespace-Services-MyClassName.svc?wsdl
Use "-" for the "."

WCF REST URIs ending in %20 fail with 404

A WCF REST web service provides a lookup in the format:
https://mysite/mycontract/search/{searchtext}
A search text of hello, or hello%20world, and the service performs correctly. However, when using text ending in whitespace as in https://mysite/mycontract/search/hello%20 the service will fail with a 404. There is no custom routing.
What limitations in wcf routing causes this, and what workarounds (ideally besides changing the uri structure) are available?
Edit w/ additional implementation info:
contract
[ServiceContract(SessionMode = SessionMode.NotAllowed)]
public interface IPointOfSale
{
.......
[WebInvoke(UriTemplate = "search/{SKU}", Method = "GET")]
System.Xml.Linq.XElement ProductLookup(string SKU);
}
method
public XElement ProductLookup(string SKU)
{
//product search here.
}
I have been working with the same issue today, and found other posts telling that, in .NET 4, the solution lies in setting the following in web.config:
<httpRuntime relaxedUrlToFileSystemMapping="true" />
This solved the problem for me!

Why am I having so much trouble uploading a file in WCF4?

This has stumped me now for over 4 hours. I can't find a simple example anywhere?
My web application has a WCF Data Service, I would love to be able to just upload an image to a custom operation on that.
Alternatively I have WCF REST TEMPLATE SERVICE that has only a .cs, NO .config to play with and NO .svc file. It does have a route in the global.asax
// Edit the base address of Service1 by replacing the "Service1" string below
RouteTable.Routes.Add(new ServiceRoute("upload", new WebServiceHostFactory(), typeof(UploadService)));
My operation looks like this:
[WebInvoke(Method ="POST", UriTemplate = "update-pic/{id}")]
public Message UploadPic(string id, Stream fileContents)
{
System.Drawing.Image.FromStream(fileContents).Save(string.Format("{0:ddmmss}.jpg"));
return WebOperationContext.Current.CreateTextResponse("Success: " + id);
}
But no matter what I do on the client, when I call the service I get a 400 response. I could facing problems with message size limits, but I don't know how to configure this with the WCF RestTemplate style.
If I do not set the anything to the response stream, then I manage to hit the service.
Does anyone have an end to end service and client example for WCF4 - I'm not interested in 3.5

WCF classes not reflecting

I have created a WCF service for my project one of the classes in the service is not reflecting when i add the WCF service to my project, though the class is marked as <DataContract(), Serializable()> _
kindly help
I don't really understand it, but if im right you should add that class as a ServiceKnownType:
http://msdn.microsoft.com/en-us/library/ms554667.aspx

Silverlight WCF service

Initially created a WCF service with one method and everything works fine. I tried to add a new method to the service and for some reason when I try to update the service it does not find this new method. Any advice?
Is the service in the same solution as the Silverlight app? That seems to help when updating the service. Also, are you sure your service is compiling and starting correctly? If there is a problem, VS can't read the WSDL and nothing gets updated.
Other than that, sometimes VS just doesn't refresh it right for me and it's faster just to re-create it.
I had to add
[OperationContract]
Above each new function in the IService1.cs file. So now the IService1.cs file looks like this:
[ServiceContract]
public interface IService1
{
[OperationContract]
List func1();
[OperationContract]
double func2();
}