Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET WCF .NET4
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:
 
    [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:
 
    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 26-Sep-12 21:18pm
Code09876.7K
Edited 26-Sep-12 21:40pm
v3
Comments
BobJanova at 27-Sep-12 5:10am
   
Perhaps you used to have it defined as POST and haven't updated the client?
Code0987 at 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 at 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 at 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 at 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?
Code0987 at 27-Sep-12 10:57am
   
I'm not using service reference. I'm using WebChannelFactory factory.
BobJanova at 27-Sep-12 11:04am
   
Oh right, sorry. When you look at the .svc in a browser, is the method defined correctly? Does it look different for the local and remote servers?
 
This is some form of configuration error and frankly there's no way anyone on here is going to be able to solve it for you.

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

  Print Answers RSS
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 27 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100