It's nice to look at the combination of the WCF Service and Web requests, but I cannot configure it myself (no web host is used). So I studied the configuration of the WCF binding.
- The binding of endpoint must be webhttpbinding.
- Add webhttp.
The sample configuration file is as follows:
<?XML
Version="1.0"
Encoding="UTF-8"?>
<Configuration>
<System. Web>
<Compilation
Debug="True"/>
</System. Web>
<! --When deploying the service library project, the content of the config file must be added to the host's
App. config file. system. configuration does not support config files for libraries.-->
<System. servicemodel>
<Services>
<Service
Name="Services. playerservice"
Behaviorconfiguration="BH">
<Host>
<Baseaddresses>
<Add
Baseaddress="Http: // localhost: 8731/playerservice/"/>
</Baseaddresses>
</Host>
<! --Service endpoints-->
unless fully qualified, address is relative to base address supplied above -->
endpoint
address =" "
binding =" basichttpbinding "
contract =" contrat. iplayerservice "
behaviorconfiguration =" Web " > endpoint >< br>
<! --Metadata endpoints-->
<! --The metadata exchange endpoint is used by the Service to describe itself to clients.-->
<! --This endpoint does not use a secure binding and shoshould be secured or removed before deployment-->
<Endpoint
Address="MEX"
Binding="Mexico httpbinding"
Contract="Imetadataexchange"/>
</Service>
</Services>
<Behaviors>
<Endpointbehaviors>
<Behavior
Name="Web">
<Webhttp/>
</Behavior>
</Endpointbehaviors>
<Servicebehaviors>
<Behavior
Name="BH">
<! --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="False"/>
</Behavior>
</Servicebehaviors>
</Behaviors>
</System. servicemodel>
</Configuration>