Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
What could be the reason for WCF Service on webHttpBinding on ASP.Net server not getting data from client using WebChannelFactory, only the method is called but parameters are not send to server.

Server:

C#
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[DataContract]
public class MyService : IMyService
{
    [WebGet] // Using WebPost causes 405 Errors
    public MyDataType GetMyData(string input) // input is always empty. ?
    {


Client:

C#
WebChannelFactory<IMyService> factory =
    new WebChannelFactory<IMyService>(
        new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly),
        new Uri("http://127.0.0.1/Services/MyService.svc")
    );

 factory.Endpoint.Behaviors.Add(new WebHttpBehavior());

 IMyService service = factory.CreateChannel();

 MyDataType my = service.GetMyData("input");

 ((IClientChannel)service).Close();
Posted
Updated 26-Sep-12 20:40pm
v3
Comments
BobJanova 27-Sep-12 5:10am    
Perhaps you used to have it defined as POST and haven't updated the client?
Code0987 27-Sep-12 9:28am    
No. Nothing work, i tried all possible things. Well this used to work (and still work in remote server) but not in local server. I've VS12, II8.
BobJanova 27-Sep-12 10:15am    
You have obviously not tried 'all possible things', or you'd have tripped over the one that makes it work ;)

There is very little to go on here. You've posted some code that should work. Have you tried looking at the HTTP requests that are actually being made, to see whether the argument is being passed?

Does it work if you change the URL to the remote server and re-run? If so it's something to do with your local server.
Code0987 27-Sep-12 10:52am    
This works when I make requests from Chrome or Fiddler but doesn't work with ChannelFactory, it doesn't send argument data. Sometimes 400 and 405 error occur though.
BobJanova 27-Sep-12 10:56am    
Then the problem is with the client. Are you -sure- you updated the service reference after you made this a GET method?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900