Database Reference
In-Depth Information
return (new Response() { tmString = "basic Response" });
}
}
}
The class attributes
ServiceContract
on line 13 and
AspNetCompatibility
Requirements
on line 14 define what this class can do. The
DataContract
attribute on the response class on line 17 defines what this web service is going
to return—in this case, just a string. The reason you have to return a string and
not a pure JSON object is the naming convention of
$area
and
$color
, which
you have to fix. C# does not support $ or a space in a name in class, whereas
the InfoVis library requires them. You'll get to that a little later in this section.
Finally, the method attributes
OperationContract
on line 24 and
WebInvoke
on line 25 tell the web service that this is a
POST
service—this is the method
that the web page will use to communicate to the web service, as opposed to
the other type of service, the
GET
service.
Next, open the
web.config
file—it is located in your solution explorer in
Visual Studio directly underneath the
OECD.svc
file you have been working
on. Replace the contents with the following:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="OECDSvc.OECD">
<webHttp />
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the
value below to false and remove the metadata endpoint
above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging
purposes, set the value below to true. Set to false
before deployment to avoid disclosing exception
information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>