WCF Client Binding
The following describes special binding requirements related with creating CIMIS Web API client applictaions using Microsoft Windows Communication Foundataion (WCF).
Requirements
The CIMIS Web API SOAP services are made available through the DWR Enterprise Service Bus (ESB). The ESB requires requests to be made using username authentication over HTTP with responses returned without a security header.
Developing a client that conforms to this scheme can be challenging since technology platforms like WCF do not have default bindings that support this configuration. The challenges are that by default WCF expects transport security (HTTPS scheme) when using username authentication and does not accept unsecured responses for secured requests.
Fortunately both challenges are overcome with custom binding. A custom binding DLL may be downloaded for use with WCF. Simply reference the DLL in your client project and associate the custom binding with your client endpoint.
web.config or app.config
<configuration> <system.serviceModel> <extensions> <bindingExtensions> <add name="CimisWebApiBinding" type="Cimis.Web.Api.Binding.CimisWebApiCollectionElement, CimisWebApiBinding"/> </bindingExtensions> </extensions> <bindings> <CimisWebApiBinding> <binding name="ClientCimisWebApiBinding" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:02:00" sendTimeout="00:02:00" messageVersion="Soap11"/> </cimisWebApiBinding> </bindings> <client> <endpoint address="https://et.water.ca.gov/CimisWebApiService_vs" binding="CimisWebApiBinding" bindingConfiguration="ClientCimisWebApiBinding" contract="CimisSoapServiceReference.ICimisWebApiService" name="CimisWebApiService_vs"/> </client> </system.serviceModel> </configuration>
Resources
- The CIMIS Web API WSDL may be downloaded here.
- The CIMIS Web API custom binding DLL may be downloaded here.
Sample Request
<?xml version="1.0" encoding="utf-16"?> <s:Envelope xmlns:s="https://schemas.xmlsoap.org/soap/envelope/" xmlns:u="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <s:Header> <o:Security xmlns:o="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1"> <u:Timestamp u:Id="_0"> <u:Created>2012-10-18T20:13:21.898Z</u:Created> <u:Expires>2012-10-18T20:18:21.898Z</u:Expires> </u:Timestamp> <o:UsernameToken u:Id="uuid-48f9cfb4-58b6-402a-8e4a-067bdee1d370-1"> <o:Username>??????????</o:Username> <o:Password>??????????</o:Password> </o:UsernameToken> </o:Security> </s:Header> <s:Body> <GetStation xmlns="https://et.water.ca.gov"> <stationNbr>2</stationNbr> </GetStation> </s:Body> </s:Envelope>
Sample Response
<?xml version="1.0" encoding="utf-16"?> <s:Envelope xmlns:s="https://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <GetStationResponse xmlns="https://et.water.ca.gov"> <GetStationResult> <data xmlns="" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"> <stations> <station station-nbr="2" name="FivePoints" city="Five Points" regional-office="South Central Region Office" county="Fresno"> <connect-date>6/7/1982</connect-date> <disconnect-date>12/31/2030</disconnect-date> <is-active>True</is-active> <is-eto-station>True</is-eto-station> <elevation>285</elevation> <ground-cover>Grass</ground-cover> <hms-latitude>36?20'10N / 36.3360</hms-latitude> <hms-longitude>-120?6'47W / -120.1130</hms-longitude> <zip-codes> <zip-code>93624</zip-code> </zip-codes> <siting-desc/> </station> </stations> </data> </GetStationResult> </GetStationResponse> </s:Body> </s:Envelope>