Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

WCF Service hosted by Windows Service

 
 
Thread Tools Display Modes
Old 06-02-2007   #1 (permalink)
Craig
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
 
Old 06-02-2007   #2 (permalink)
Aneesh P
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].

 
Old 06-02-2007   #3 (permalink)
Craig
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">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].
>
>

 
Old 06-03-2007   #4 (permalink)
Aneesh P
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">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.

 
Old 06-03-2007   #5 (permalink)
Craig
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">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.
>
>

 
Old 06-04-2007   #6 (permalink)
Aneesh P
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">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

 
Old 06-04-2007   #7 (permalink)
Craig
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">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
>
>

 
Old 06-05-2007   #8 (permalink)
Aneesh P
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">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;}
.......................
}



 
 
 

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








Vistax64.com 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 2005-2008

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 47 48 49