Reggie Chen

Hi,

Where can I find a minimum, simple example on creating a POX service with IIS in ORCA 2 with .NET 3.5 b2 I just need a minimum example without thing like REST, to respond to request like http://myserver/myservice.svc/pox/myservice x=3 .

I am not very successful finding a simple example to work with the newest .NET 3.5 There are some examples with 3.0 using obsolete attributes and web config tags. It should be very simple to do what I want in 3.5 b2. I want my WCF service to emit loose XAML stream to internet explorer. Can someone help me with a basic example

Regards,

Reggie



Re: Windows Communication Foundation (Indigo) Simple POX example

Reggie Chen

Hi,

I was able to create some minimum example based on XMLAjaxSerive example with [WebGet].

Here is what my svc look like

<%@ServiceHost language=c# Debug="true" Service="Microsoft.Ajax.Samples.CalculatorService" %>

The interface for contract...

Code Block

[ServiceContract]

public interface IJSON_Service

{

[OperationContract]

//[WebGet]

[WebGet(ResponseFormat = WebMessageFormat.Xml)]

string JEcho(string s);

}

and web.config

Code Block

<system.serviceModel>

<behaviors>

<endpointBehaviors>

<behavior name="AjaxBehavior">

<enableWebScript />

</behavior>

</endpointBehaviors>

<serviceBehaviors>

<behavior name="JSON_ServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="false" />

</behavior>

</serviceBehaviors>

</behaviors>

<bindings>

</bindings>

<services>

<service behaviorConfiguration="JSON_ServiceBehavior" name="JSON_Service">

<endpoint address="JSON" binding="webHttpBinding" behaviorConfiguration="AjaxBehavior" contract="IJSON_Service" />

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

</service>

</services>

</system.serviceModel>

The service, running on my local asp.net server, does respond with XML from http://localhost:52438/POXService/JSON_Service.svc/JSON/JEcho s=test2134345

and if I remove RespondFormat from webget, I got JSON message back like {"d":"test2134345"}.

My question is, I should be able to specify

[WebInvoke(ResponseFormat=WebMessageFormat.Xml)] like the example, but the asp.net web server repond back with endpoint not found. What went wrong with my configuration It seemed wheather I want JSON or POX, the [webget] attribute need to be there.

How do I get rid of "d" in JSON message I want to produce loose-xaml XML stream to the browser. What are the other attributes I need to pay attenation

Please help!

Reggie





Re: Windows Communication Foundation (Indigo) Simple POX example

Carlos Figueira - MSFT

This should do what you need:

Contract / implementation:

Code Block

namespace Samples
{
[ServiceContract(Namespace="")]
public interface ITest
{
[OperationContract]
[WebGet(UriTemplate="myservice x={x}")]
string Operation(int x);
}

public class MyService : ITest
{
public string Operation(int x)
{
return "Received " + x;
}
}
}


web.config:

Code Block
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Samples.MyService">
<endpoint address="pox" behaviorConfiguration="WebBehavior" binding="webHttpBinding"
bindingConfiguration="" contract="Samples.ITest" />
</service>
</services>
</system.serviceModel>

This creates the endpoint at address "pox" under the .svc file. And a request to http://serverName/vDirName/service.svc/pox/myservice x=3 returns the string (in XML format).





Re: Windows Communication Foundation (Indigo) Simple POX example

Carlos Figueira - MSFT

The "{d:}" is a format used between a WCF service and an ASP.NET AJAX client. If you don't want this, you should not use the <enableWebScript> behavior element, but the <webHttp> element, as shown in my previous post on this thread.

By default, <enableWebScript> endpoints have request/response format set to JSON, and <webHttp> endpoints have request/response format set to XML.





Re: Windows Communication Foundation (Indigo) Simple POX example

Reggie Chen

I see. Can you tell me why replacing WebGet with [WebInvoke(ResponseFormat=WebMessageFormat.Xml)] would cause "EndPoint not found" Is it because WebInvok does HTTP Post I try sending HTTP request as following

Code Block

POST /POXService/JSON_Service.svc/JSON/JEcho HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0
Content-Length: 11
Host: LOCALHOST
Content-Type: application/x-www-form-urlencoded

s=test43532

instead of url like http://localhost:52438/POXService/JSON_Service.svc/JSON/JEcho s=test2134345 This time, it doesn't complain about endpoint, but I don't get anything back either. What went wrong