Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - WCF Service hosted by Windows Service

 
 
Old 06-02-2007   #1 (permalink)
Craig


 
 

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

My System SpecsSystem Spec
Old 06-02-2007   #2 (permalink)
Aneesh P


 
 

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].

My System SpecsSystem Spec
Old 06-03-2007   #3 (permalink)
Craig


 
 

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">aestinationUnreachable</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].
>
>

My System SpecsSystem Spec
Old 06-03-2007   #4 (permalink)
Aneesh P


 
 

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">aestinationUnreachable</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.

My System SpecsSystem Spec
Old 06-03-2007   #5 (permalink)
Craig


 
 

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">aestinationUnreachable</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.
>
>

My System SpecsSystem Spec
Old 06-04-2007   #6 (permalink)
Aneesh P


 
 

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">aestinationUnreachable</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

My System SpecsSystem Spec
Old 06-04-2007   #7 (permalink)
Craig


 
 

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">aestinationUnreachable</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
>
>

My System SpecsSystem Spec
Old 06-05-2007   #8 (permalink)
Aneesh P


 
 

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">aestinationUnreachable</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;}
.......................
}



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
WCF service hosted in IIS .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46