![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest
Posts: n/a
| WCF Service hosted by Windows Service Hi I have a WCF service that is hosted in Windows Service. As a sample client I can access the WCF service by adding a Web Reference pointing to the WCF service URL, generating the proxy class. My WCF service has one method as follows: public string ProcessMessage(string message) { return "message=" + message; } I want to develop another client which does NOT use the proxy code, instead invoke the method via WebHttpRequest. Here is the method to do that: private static void ProcessHttpPostRequest() { string param = "message=test"; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://localhost:8000/myService/ProcessMessage"); webRequest.Headers.Add("Authorization", "hello;world"); webRequest.Method = "POST"; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.ContentLength = param.Length; using (StreamWriter writer = new StreamWriter(webRequest.GetRequestStream())) { writer.Write(param); } try { using(HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()){ using (StreamReader reader = new StreamReader(webResponse.GetResponseStream())) { Console.Write(reader.ReadToEnd()); } } } catch (Exception exception) { Console.Write(exception.Message); } } I end up with a 500 error returned from the server. Any ideas on how to call a WCF service from WebHttpRequest? Craig |
| | #2 (permalink) |
| Guest
Posts: n/a
| Re: WCF Service hosted by Windows Service On Jun 2, 3:55 pm, Craig <C...@discussions.microsoft.com> wrote: > Hi > > I have a WCF service that is hosted in Windows Service. As a sample client > I can access the WCF service by adding a Web Reference pointing to the WCF > service URL, generating the proxy class. > > My WCF service has one method as follows: > > public string ProcessMessage(string message) { > return "message=" + message; > > } > > I want to develop another client which does NOT use the proxy code, instead > invoke the method via WebHttpRequest. > > Here is the method to do that: > > private static void ProcessHttpPostRequest() { > string param = "message=test"; > HttpWebRequest webRequest = > (HttpWebRequest)WebRequest.Create("http://localhost:8000/myService/ProcessMessage"); > webRequest.Headers.Add("Authorization", "hello;world"); > webRequest.Method = "POST"; > webRequest.ContentType = "application/x-www-form-urlencoded"; > webRequest.ContentLength = param.Length; > > using (StreamWriter writer = new > StreamWriter(webRequest.GetRequestStream())) { > writer.Write(param); > } > > try { > using(HttpWebResponse webResponse = > (HttpWebResponse)webRequest.GetResponse()){ > using (StreamReader reader = new > StreamReader(webResponse.GetResponseStream())) { > Console.Write(reader.ReadToEnd()); > } > } > } > catch (Exception exception) { > Console.Write(exception.Message); > } > } > > I end up with a 500 error returned from the server. Any ideas on how to > call a WCF service from WebHttpRequest? > > Craig Just for confirmation - Can we call [OperationContract] directly using HTTPRequest? Please check the attributes for [OperationContract]. |
| | #3 (permalink) |
| Guest
Posts: n/a
| Re: WCF Service hosted by Windows Service If I pass the following url into IE, this is the response: URL: http://localhost:8000/myService/Proc...e?message=test Response: <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> <Code> <Value>Sender</Value> <Subcode> <Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a estinationUnreachable</Value></Subcode> </Code> <Reason> <Text xml:lang="en-AU">The message with To 'http://localhost:8000/cardax/provisioning/processmessage?message=tr' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.</Text> </Reason> </Fault> My method (ProcessMessage) derives from an interface, the interface method ProcessMessage has [OperationContract] attribute, the implemented method (in the service) does not has this attribute. Craig "Aneesh P" wrote: > On Jun 2, 3:55 pm, Craig <C...@discussions.microsoft.com> wrote: > > Hi > > > > I have a WCF service that is hosted in Windows Service. As a sample client > > I can access the WCF service by adding a Web Reference pointing to the WCF > > service URL, generating the proxy class. > > > > My WCF service has one method as follows: > > > > public string ProcessMessage(string message) { > > return "message=" + message; > > > > } > > > > I want to develop another client which does NOT use the proxy code, instead > > invoke the method via WebHttpRequest. > > > > Here is the method to do that: > > > > private static void ProcessHttpPostRequest() { > > string param = "message=test"; > > HttpWebRequest webRequest = > > (HttpWebRequest)WebRequest.Create("http://localhost:8000/myService/ProcessMessage"); > > webRequest.Headers.Add("Authorization", "hello;world"); > > webRequest.Method = "POST"; > > webRequest.ContentType = "application/x-www-form-urlencoded"; > > webRequest.ContentLength = param.Length; > > > > using (StreamWriter writer = new > > StreamWriter(webRequest.GetRequestStream())) { > > writer.Write(param); > > } > > > > try { > > using(HttpWebResponse webResponse = > > (HttpWebResponse)webRequest.GetResponse()){ > > using (StreamReader reader = new > > StreamReader(webResponse.GetResponseStream())) { > > Console.Write(reader.ReadToEnd()); > > } > > } > > } > > catch (Exception exception) { > > Console.Write(exception.Message); > > } > > } > > > > I end up with a 500 error returned from the server. Any ideas on how to > > call a WCF service from WebHttpRequest? > > > > Craig > > Just for confirmation - Can we call [OperationContract] directly using > HTTPRequest? Please check the attributes for [OperationContract]. > > |
| | #4 (permalink) |
| Guest
Posts: n/a
| Re: WCF Service hosted by Windows Service On Jun 3, 9:24 am, Craig <C...@discussions.microsoft.com> wrote: > If I pass the following url into IE, this is the response: > > URL: http://localhost:8000/myService/Proc...e?message=test > > Response: > <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> > <Code> > <Value>Sender</Value> > <Subcode> > <Value > xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a estinationUnreachable</Value>> </Subcode> > </Code> > <Reason> > <Text xml:lang="en-AU">The message with To > 'http://localhost:8000/cardax/provisioning/processmessage?message=tr'cannot > be processed at the receiver, due to an AddressFilter mismatch at the > EndpointDispatcher. Check that the sender and receiver's EndpointAddresses > agree.</Text> > </Reason> > </Fault> > > My method (ProcessMessage) derives from an interface, the interface method > ProcessMessage has [OperationContract] attribute, the implemented method (in > the service) does not has this attribute. > > Craig > > > > "Aneesh P" wrote: > > On Jun 2, 3:55 pm, Craig <C...@discussions.microsoft.com> wrote: > > > Hi > > > > I have a WCF service that is hosted in Windows Service. As a sample client > > > I can access the WCF service by adding a Web Reference pointing to the WCF > > > service URL, generating the proxy class. > > > > My WCF service has one method as follows: > > > > public string ProcessMessage(string message) { > > > return "message=" + message; > > > > } > > > > I want to develop another client which does NOT use the proxy code, instead > > > invoke the method via WebHttpRequest. > > > > Here is the method to do that: > > > > private static void ProcessHttpPostRequest() { > > > string param = "message=test"; > > > HttpWebRequest webRequest = > > > (HttpWebRequest)WebRequest.Create("http://localhost:8000/myService/ProcessMessage"); > > > webRequest.Headers.Add("Authorization", "hello;world"); > > > webRequest.Method = "POST"; > > > webRequest.ContentType = "application/x-www-form-urlencoded"; > > > webRequest.ContentLength = param.Length; > > > > using (StreamWriter writer = new > > > StreamWriter(webRequest.GetRequestStream())) { > > > writer.Write(param); > > > } > > > > try { > > > using(HttpWebResponse webResponse = > > > (HttpWebResponse)webRequest.GetResponse()){ > > > using (StreamReader reader = new > > > StreamReader(webResponse.GetResponseStream())) { > > > Console.Write(reader.ReadToEnd()); > > > } > > > } > > > } > > > catch (Exception exception) { > > > Console.Write(exception.Message); > > > } > > > } > > > > I end up with a 500 error returned from the server. Any ideas on how to > > > call a WCF service from WebHttpRequest? > > > > Craig > > > Just for confirmation - Can we call [OperationContract] directly using > > HTTPRequest? Please check the attributes for [OperationContract].- Hide quoted text - > > - Show quoted text - Try using @WebMethod(action="processmessage") for the implemented method. This would set the soapaction value in WSDL. I'm not sure this is a solution for your problem. This kind of error happened when the soapaction value was empty. In that case WCF client sends empty string as the value of action header. |
| | #5 (permalink) |
| Guest
Posts: n/a
| Re: WCF Service hosted by Windows Service @WebMethod? [WebMethod(...)] is an attribute from the System.Web.Services namespace. Is that what you're suggesting? If so, then action is not a argument to WebMethod. Craig "Aneesh P" wrote: > On Jun 3, 9:24 am, Craig <C...@discussions.microsoft.com> wrote: > > If I pass the following url into IE, this is the response: > > > > URL: http://localhost:8000/myService/Proc...e?message=test > > > > Response: > > <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> > > <Code> > > <Value>Sender</Value> > > <Subcode> > > <Value > > xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a estinationUnreachable</Value>> > </Subcode> > > </Code> > > <Reason> > > <Text xml:lang="en-AU">The message with To > > 'http://localhost:8000/cardax/provisioning/processmessage?message=tr'cannot > > be processed at the receiver, due to an AddressFilter mismatch at the > > EndpointDispatcher. Check that the sender and receiver's EndpointAddresses > > agree.</Text> > > </Reason> > > </Fault> > > > > My method (ProcessMessage) derives from an interface, the interface method > > ProcessMessage has [OperationContract] attribute, the implemented method (in > > the service) does not has this attribute. > > > > Craig > > > > > > > > "Aneesh P" wrote: > > > On Jun 2, 3:55 pm, Craig <C...@discussions.microsoft.com> wrote: > > > > Hi > > > > > > I have a WCF service that is hosted in Windows Service. As a sample client > > > > I can access the WCF service by adding a Web Reference pointing to the WCF > > > > service URL, generating the proxy class. > > > > > > My WCF service has one method as follows: > > > > > > public string ProcessMessage(string message) { > > > > return "message=" + message; > > > > > > } > > > > > > I want to develop another client which does NOT use the proxy code, instead > > > > invoke the method via WebHttpRequest. > > > > > > Here is the method to do that: > > > > > > private static void ProcessHttpPostRequest() { > > > > string param = "message=test"; > > > > HttpWebRequest webRequest = > > > > (HttpWebRequest)WebRequest.Create("http://localhost:8000/myService/ProcessMessage"); > > > > webRequest.Headers.Add("Authorization", "hello;world"); > > > > webRequest.Method = "POST"; > > > > webRequest.ContentType = "application/x-www-form-urlencoded"; > > > > webRequest.ContentLength = param.Length; > > > > > > using (StreamWriter writer = new > > > > StreamWriter(webRequest.GetRequestStream())) { > > > > writer.Write(param); > > > > } > > > > > > try { > > > > using(HttpWebResponse webResponse = > > > > (HttpWebResponse)webRequest.GetResponse()){ > > > > using (StreamReader reader = new > > > > StreamReader(webResponse.GetResponseStream())) { > > > > Console.Write(reader.ReadToEnd()); > > > > } > > > > } > > > > } > > > > catch (Exception exception) { > > > > Console.Write(exception.Message); > > > > } > > > > } > > > > > > I end up with a 500 error returned from the server. Any ideas on how to > > > > call a WCF service from WebHttpRequest? > > > > > > Craig > > > > > Just for confirmation - Can we call [OperationContract] directly using > > > HTTPRequest? Please check the attributes for [OperationContract].- Hide quoted text - > > > > - Show quoted text - > > Try using @WebMethod(action="processmessage") for the implemented > method. This would set the soapaction value in WSDL. I'm not sure this > is a solution for your problem. This kind of error happened when the > soapaction value was empty. In that case WCF client sends empty > string as the value of action header. > > |
| | #6 (permalink) |
| Guest
Posts: n/a
| Re: WCF Service hosted by Windows Service On Jun 3, 12:46 pm, Craig <C...@discussions.microsoft.com> wrote: > @WebMethod? > > [WebMethod(...)] is an attribute from the System.Web.Services namespace. Is > that what you're suggesting? If so, then action is not a argument to > WebMethod. > > Craig > > > > "Aneesh P" wrote: > > On Jun 3, 9:24 am, Craig <C...@discussions.microsoft.com> wrote: > > > If I pass the following url into IE, this is the response: > > > > URL: http://localhost:8000/myService/Proc...e?message=test > > > > Response: > > > <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> > > > <Code> > > > <Value>Sender</Value> > > > <Subcode> > > > <Value > > > xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a estinationUnreachable</Value>> > > </Subcode> > > > </Code> > > > <Reason> > > > <Text xml:lang="en-AU">The message with To > > > 'http://localhost:8000/cardax/provisioning/processmessage?message=tr'c... > > > be processed at the receiver, due to an AddressFilter mismatch at the > > > EndpointDispatcher. Check that the sender and receiver's EndpointAddresses > > > agree.</Text> > > > </Reason> > > > </Fault> > > > > My method (ProcessMessage) derives from an interface, the interface method > > > ProcessMessage has [OperationContract] attribute, the implemented method (in > > > the service) does not has this attribute. > > > > Craig > > > > "Aneesh P" wrote: > > > > On Jun 2, 3:55 pm, Craig <C...@discussions.microsoft.com> wrote: > > > > > Hi > > > > > > I have a WCF service that is hosted in Windows Service. As a sample client > > > > > I can access the WCF service by adding a Web Reference pointing to the WCF > > > > > service URL, generating the proxy class. > > > > > > My WCF service has one method as follows: > > > > > > public string ProcessMessage(string message) { > > > > > return "message=" + message; > > > > > > } > > > > > > I want to develop another client which does NOT use the proxy code, instead > > > > > invoke the method via WebHttpRequest. > > > > > > Here is the method to do that: > > > > > > private static void ProcessHttpPostRequest() { > > > > > string param = "message=test"; > > > > > HttpWebRequest webRequest = > > > > > (HttpWebRequest)WebRequest.Create("http://localhost:8000/myService/ProcessMessage"); > > > > > webRequest.Headers.Add("Authorization", "hello;world"); > > > > > webRequest.Method = "POST"; > > > > > webRequest.ContentType = "application/x-www-form-urlencoded"; > > > > > webRequest.ContentLength = param.Length; > > > > > > using (StreamWriter writer = new > > > > > StreamWriter(webRequest.GetRequestStream())) { > > > > > writer.Write(param); > > > > > } > > > > > > try { > > > > > using(HttpWebResponse webResponse = > > > > > (HttpWebResponse)webRequest.GetResponse()){ > > > > > using (StreamReader reader = new > > > > > StreamReader(webResponse.GetResponseStream())) { > > > > > Console.Write(reader.ReadToEnd()); > > > > > } > > > > > } > > > > > } > > > > > catch (Exception exception) { > > > > > Console.Write(exception.Message); > > > > > } > > > > > } > > > > > > I end up with a 500 error returned from the server. Any ideas on how to > > > > > call a WCF service from WebHttpRequest? > > > > > > Craig > > > > > Just for confirmation - Can we call [OperationContract] directly using > > > > HTTPRequest? Please check the attributes for [OperationContract].- Hide quoted text - > > > > - Show quoted text - > > > Try using @WebMethod(action="processmessage") for the implemented > > method. This would set the soapaction value in WSDL. I'm not sure this > > is a solution for your problem. This kind of error happened when the > > soapaction value was empty. In that case WCF client sends empty > > string as the value of action header.- Hide quoted text - > > - Show quoted text - I was referring to non-dotnet library..sorry for that.. have you seen the description for similiar problem here: http://developers.de/blogs/damir_dob...elivering.aspx |
| | #7 (permalink) |
| Guest
Posts: n/a
| Re: WCF Service hosted by Windows Service Hi Aneesh My non-WCF client would typically call the WCF service as though it it like a web service; the proxy generation is via WCF service WSDL, not svcutil. So essentially I need to pass either a soap token of add to the Http request header ("Authorization", "hello;world"). The binding must be basicHttpBinding and security will be transport using SSL service certificate. I can get the transport binding working ok, when I call the service from WSDL proxy generation, I just can't seem to extract the user name and password from the OperationContext, frustrating as hell. Craig I get a 404 error to the link: http://developers.de/blogs/damir_dob...elivering.aspx "Aneesh P" wrote: > On Jun 3, 12:46 pm, Craig <C...@discussions.microsoft.com> wrote: > > @WebMethod? > > > > [WebMethod(...)] is an attribute from the System.Web.Services namespace. Is > > that what you're suggesting? If so, then action is not a argument to > > WebMethod. > > > > Craig > > > > > > > > "Aneesh P" wrote: > > > On Jun 3, 9:24 am, Craig <C...@discussions.microsoft.com> wrote: > > > > If I pass the following url into IE, this is the response: > > > > > > URL: http://localhost:8000/myService/Proc...e?message=test > > > > > > Response: > > > > <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> > > > > <Code> > > > > <Value>Sender</Value> > > > > <Subcode> > > > > <Value > > > > xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a estinationUnreachable</Value>> > > > </Subcode> > > > > </Code> > > > > <Reason> > > > > <Text xml:lang="en-AU">The message with To > > > > 'http://localhost:8000/cardax/provisioning/processmessage?message=tr'c... > > > > be processed at the receiver, due to an AddressFilter mismatch at the > > > > EndpointDispatcher. Check that the sender and receiver's EndpointAddresses > > > > agree.</Text> > > > > </Reason> > > > > </Fault> > > > > > > My method (ProcessMessage) derives from an interface, the interface method > > > > ProcessMessage has [OperationContract] attribute, the implemented method (in > > > > the service) does not has this attribute. > > > > > > Craig > > > > > > "Aneesh P" wrote: > > > > > On Jun 2, 3:55 pm, Craig <C...@discussions.microsoft.com> wrote: > > > > > > Hi > > > > > > > > I have a WCF service that is hosted in Windows Service. As a sample client > > > > > > I can access the WCF service by adding a Web Reference pointing to the WCF > > > > > > service URL, generating the proxy class. > > > > > > > > My WCF service has one method as follows: > > > > > > > > public string ProcessMessage(string message) { > > > > > > return "message=" + message; > > > > > > > > } > > > > > > > > I want to develop another client which does NOT use the proxy code, instead > > > > > > invoke the method via WebHttpRequest. > > > > > > > > Here is the method to do that: > > > > > > > > private static void ProcessHttpPostRequest() { > > > > > > string param = "message=test"; > > > > > > HttpWebRequest webRequest = > > > > > > (HttpWebRequest)WebRequest.Create("http://localhost:8000/myService/ProcessMessage"); > > > > > > webRequest.Headers.Add("Authorization", "hello;world"); > > > > > > webRequest.Method = "POST"; > > > > > > webRequest.ContentType = "application/x-www-form-urlencoded"; > > > > > > webRequest.ContentLength = param.Length; > > > > > > > > using (StreamWriter writer = new > > > > > > StreamWriter(webRequest.GetRequestStream())) { > > > > > > writer.Write(param); > > > > > > } > > > > > > > > try { > > > > > > using(HttpWebResponse webResponse = > > > > > > (HttpWebResponse)webRequest.GetResponse()){ > > > > > > using (StreamReader reader = new > > > > > > StreamReader(webResponse.GetResponseStream())) { > > > > > > Console.Write(reader.ReadToEnd()); > > > > > > } > > > > > > } > > > > > > } > > > > > > catch (Exception exception) { > > > > > > Console.Write(exception.Message); > > > > > > } > > > > > > } > > > > > > > > I end up with a 500 error returned from the server. Any ideas on how to > > > > > > call a WCF service from WebHttpRequest? > > > > > > > > Craig > > > > > > > Just for confirmation - Can we call [OperationContract] directly using > > > > > HTTPRequest? Please check the attributes for [OperationContract].- Hide quoted text - > > > > > > - Show quoted text - > > > > > Try using @WebMethod(action="processmessage") for the implemented > > > method. This would set the soapaction value in WSDL. I'm not sure this > > > is a solution for your problem. This kind of error happened when the > > > soapaction value was empty. In that case WCF client sends empty > > > string as the value of action header.- Hide quoted text - > > > > - Show quoted text - > > I was referring to non-dotnet library..sorry for that.. > > have you seen the description for similiar problem here: > http://developers.de/blogs/damir_dob...elivering.aspx > > |
| | #8 (permalink) |
| Guest
Posts: n/a
| Re: WCF Service hosted by Windows Service On Jun 4, 11:37 am, Craig <C...@discussions.microsoft.com> wrote: > Hi Aneesh > > My non-WCF client would typically call the WCF service as though it it like > a web service; the proxy generation is via WCF service WSDL, not svcutil. So > essentially I need to pass either a soap token of add to the Http request > header ("Authorization", "hello;world"). The binding must be > basicHttpBinding and security will be transport using SSL service certificate. > > I can get the transport binding working ok, when I call the service from > WSDL proxy generation, I just can't seem to extract the user name and > password from the OperationContext, frustrating as hell. > > Craig > > I get a 404 error to the link: http://developers.de/blogs/damir_dob.../04/Custom-Cha... > > > > "Aneesh P" wrote: > > On Jun 3, 12:46 pm, Craig <C...@discussions.microsoft.com> wrote: > > > @WebMethod? > > > > [WebMethod(...)] is an attribute from the System.Web.Services namespace. Is > > > that what you're suggesting? If so, then action is not a argument to > > > WebMethod. > > > > Craig > > > > "Aneesh P" wrote: > > > > On Jun 3, 9:24 am, Craig <C...@discussions.microsoft.com> wrote: > > > > > If I pass the following url into IE, this is the response: > > > > > > URL: http://localhost:8000/myService/Proc...e?message=test > > > > > > Response: > > > > > <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> > > > > > <Code> > > > > > <Value>Sender</Value> > > > > > <Subcode> > > > > > <Value > > > > > xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a estinationUnreachable</Value>> > > > > </Subcode> > > > > > </Code> > > > > > <Reason> > > > > > <Text xml:lang="en-AU">The message with To > > > > > 'http://localhost:8000/cardax/provisioning/processmessage?message=tr'c... > > > > > be processed at the receiver, due to an AddressFilter mismatch at the > > > > > EndpointDispatcher. Check that the sender and receiver's EndpointAddresses > > > > > agree.</Text> > > > > > </Reason> > > > > > </Fault> > > > > > > My method (ProcessMessage) derives from an interface, the interface method > > > > > ProcessMessage has [OperationContract] attribute, the implemented method (in > > > > > the service) does not has this attribute. > > > > > > Craig > > > > > > "Aneesh P" wrote: > > > > > > On Jun 2, 3:55 pm, Craig <C...@discussions.microsoft.com> wrote: > > > > > > > Hi > > > > > > > > I have a WCF service that is hosted in Windows Service. As a sample client > > > > > > > I can access the WCF service by adding a Web Reference pointing to the WCF > > > > > > > service URL, generating the proxy class. > > > > > > > > My WCF service has one method as follows: > > > > > > > > public string ProcessMessage(string message) { > > > > > > > return "message=" + message; > > > > > > > > } > > > > > > > > I want to develop another client which does NOT use the proxy code, instead > > > > > > > invoke the method via WebHttpRequest. > > > > > > > > Here is the method to do that: > > > > > > > > private static void ProcessHttpPostRequest() { > > > > > > > string param = "message=test"; > > > > > > > HttpWebRequest webRequest = > > > > > > > (HttpWebRequest)WebRequest.Create("http://localhost:8000/myService/ProcessMessage"); > > > > > > > webRequest.Headers.Add("Authorization", "hello;world"); > > > > > > > webRequest.Method = "POST"; > > > > > > > webRequest.ContentType = "application/x-www-form-urlencoded"; > > > > > > > webRequest.ContentLength = param.Length; > > > > > > > > using (StreamWriter writer = new > > > > > > > StreamWriter(webRequest.GetRequestStream())) { > > > > > > > writer.Write(param); > > > > > > > } > > > > > > > > try { > > > > > > > using(HttpWebResponse webResponse = > > > > > > > (HttpWebResponse)webRequest.GetResponse()){ > > > > > > > using (StreamReader reader = new > > > > > > > StreamReader(webResponse.GetResponseStream())) { > > > > > > > Console.Write(reader.ReadToEnd()); > > > > > > > } > > > > > > > } > > > > > > > } > > > > > > > catch (Exception exception) { > > > > > > > Console.Write(exception.Message); > > > > > > > } > > > > > > > } > > > > > > > > I end up with a 500 error returned from the server. Any ideas on how to > > > > > > > call a WCF service from WebHttpRequest? > > > > > > > > Craig > > > > > > > Just for confirmation - Can we call [OperationContract] directly using > > > > > > HTTPRequest? Please check the attributes for [OperationContract].- Hide quoted text - > > > > > > - Show quoted text - > > > > > Try using @WebMethod(action="processmessage") for the implemented > > > > method. This would set the soapaction value in WSDL. I'm not sure this > > > > is a solution for your problem. This kind of error happened when the > > > > soapaction value was empty. In that case WCF client sends empty > > > > string as the value of action header.- Hide quoted text - > > > > - Show quoted text - > > > I was referring to non-dotnet library..sorry for that.. > > > have you seen the description for similiar problem here: > >http://developers.de/blogs/damir_dob...Custom-Cha...- Hide quoted text - > > - Show quoted text - You can access the security context using two ways: ServiceSecurityContext context1 = ServiceSecurityContext.Current; ServiceSecurityContext context2 = OperationContext.Current.ServiceSecurityContext; First one uses ServiceSecurityContext class. public class ServiceSecurityContext { public static ServiceSecurityContext Current {get;} public bool IsAnonymous {get;} public IIdentity PrimaryIdentity {get;} public WindowsIdentity WindowsIdentity {get;} //More members } Latter one is to use OperationContext: public sealed class OperationContext : ... { public ServiceSecurityContext ServiceSecurityContext {get;} ....................... } |
| |
| |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| WCF service hosted in IIS | soworl | .NET General | 0 | 03-07-2008 10:56 AM |