Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed Help With AJAX-Enabled WCF Services (Please Look @ System.ServiceModel in Web.Config)
    primarykey
    data
    text
    <p>I have been having some problems with this for a few days now... I have designed a WCF Class Library - WebAPILibrary. It is under my solution which also contains my web project. </p> <p>I now am attempting to enable a AJAX/JSON response to a search query. </p> <p>In the client code examples, I see something to the effect:</p> <pre><code>function btnsrch_onclick() { var query = document.getElementById('q'); var type = document.getElementById('type'); $(document).ready(function(){ $.getJSON("http://api.domain.com/services/trade.svc?q=" + query.value + "&amp;type=" + type.value + "&amp;format=json", function(data){ $.each(data.items, function(i,item){ $("&lt;img/&gt;").attr("src", item.media.m).appendTo("#images"); if ( i == 3 ) return false; }); }); }); } </code></pre> <p><strong>MY PROBLEM IS</strong> that, up until this point, I have been happily referencing my WCF class library in my Web Project. But, now it seems I need to create a SVC file and use it to execute my javascript AJAX/JSON calls. </p> <p><strong>MY QUESTION IS:</strong></p> <p>1) How do I create the SVC file in cooperation with my WCF class library? 2) I am not quite sure what I need to put under system.ServiceModel for my web project's web.config. Could some kind soul kindly look at what I currently have and advise me on what I need to be doing?</p> <p><strong>WEB PROJECT SYSTEM.SERVICEMODEL (WEB.CONFIG):</strong></p> <pre><code>&lt;system.serviceModel&gt; &lt;bindings&gt; &lt;wsHttpBinding&gt; &lt;binding name="WSHttpBinding_ITradeService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt; &lt;security mode="Message"&gt; &lt;transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /&gt; &lt;message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;binding name="WSHttpBinding_IAuthService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt; &lt;security mode="Message"&gt; &lt;transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /&gt; &lt;message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;binding name="WSHttpBinding_IAuthService1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt; &lt;security mode="Message"&gt; &lt;transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /&gt; &lt;message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;binding name="WSHttpBinding_ITradeService1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt; &lt;security mode="Message"&gt; &lt;transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /&gt; &lt;message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/wsHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address="http://localhost:8731/Design_Time_Addresses/Trade/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITradeService" contract="ITradeService" name="WSHttpBinding_ITradeService"&gt; &lt;identity&gt; &lt;dns value="localhost:8731" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address="http://localhost:8731/Design_Time_Addresses/Authentication/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAuthService" contract="IAuthService" name="WSHttpBinding_IAuthService"&gt; &lt;identity&gt; &lt;dns value="localhost:8731" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address="http://localhost:8731/Design_Time_Addresses/Authentication/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAuthService1" contract="Trezoro.WebAPI.Authentication.IAuthService" name="WSHttpBinding_IAuthService1"&gt; &lt;identity&gt; &lt;dns value="localhost:8731" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address="http://localhost:8731/Design_Time_Addresses/Trade/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITradeService1" contract="Trezoro.WebAPI.Trade.ITradeService" name="WSHttpBinding_ITradeService1"&gt; &lt;identity&gt; &lt;dns value="localhost:8731" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; </code></pre> <p><strong>WCF CLASS LIBRARY SYSTEM.SERVICEMODEL (APP.CONFIG):</strong></p> <pre><code> &lt;system.serviceModel&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" /&gt; &lt;services&gt; &lt;service behaviorConfiguration="WebAPILibrary.WebAPIBehavior" name="Company.WebAPI.Trade.TradeService"&gt; &lt;endpoint address="" binding="wsHttpBinding" contract="Company.WebAPI.Trade.ITradeService"&gt; &lt;identity&gt; &lt;dns value="localhost:8731" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt; &lt;host&gt; &lt;baseAddresses&gt; &lt;add baseAddress="http://localhost:8731/Design_Time_Addresses/Trade/" /&gt; &lt;/baseAddresses&gt; &lt;/host&gt; &lt;/service&gt; &lt;service behaviorConfiguration="WebAPILibrary.WebAPIBehavior" name="Company.WebAPI.Authentication.AuthService"&gt; &lt;endpoint address="" binding="wsHttpBinding" contract="Company.WebAPI.Authentication.IAuthService"&gt; &lt;identity&gt; &lt;dns value="localhost:8731" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt; &lt;host&gt; &lt;baseAddresses&gt; &lt;add baseAddress="http://localhost:8731/Design_Time_Addresses/Authentication/" /&gt; &lt;/baseAddresses&gt; &lt;/host&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="WebAPILibrary.WebAPIBehavior"&gt; &lt;enableWebScript/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="WebAPILibrary.WebAPIBehavior"&gt; &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt; &lt;serviceMetadata httpGetEnabled="True"/&gt; &lt;!-- 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 --&gt; &lt;serviceDebug includeExceptionDetailInFaults="True" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload