Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF with a MVC.NET Endpoint - No parameters being passed through?
    primarykey
    data
    text
    <p>Think I might just be doing something wrong here, but I've been persisting and searching for a day or two now and I just can't figure this out.</p> <p>I've got a re-usable WCF project within my solution, and a solution-specific MVC.NET project along side it.</p> <p>Solution: -</p> <ul> <li><p>MVC.NET Project</p></li> <li><p>Class Library</p></li> <li>WCF Project</li> </ul> <p>The WCF Test Client gets the expected results. However when trying to call the WCF services through the enpoints set up in the MVC Project I'm having some issues. If no parameters are passed through from the user, it works fine. However when trying to pass parameters to the webservice, none seem to be available inside the .svc file.</p> <p>My endpoint code:</p> <pre><code>public override void RegisterArea( AreaRegistrationContext context ) { context.Routes.Add( new ServiceRoute( "Api/SOAP/Log", new ServiceHostFactory(), typeof( Log ) ) ); context.Routes.Add( new ServiceRoute( "Api/SOAP/Report", new ServiceHostFactory(), typeof( Report ) ) ); context.Routes.Add( new ServiceRoute( "Api/Rest/Log", new WebServiceHostFactory(), typeof( Log ) ) ); context.Routes.Add( new ServiceRoute( "Api/Rest/Report", new WebServiceHostFactory(), typeof( Report ) ) ); } </code></pre> <p>A Service contract:</p> <pre><code>[ServiceContract] public interface ILog { [OperationContract] [WebInvoke( Method = "POST", UriTemplate = "Search?systemName={systemName}&amp;searchType={searchType}&amp;query={query}&amp;resultCount={resultCount}&amp;ipAddress={ipAddress}")] SearchResult Search( string systemName, string searchType, string query, string resultCount, string ipAddress ); } </code></pre> <p>And a svc Service:</p> <p>public class Log : ILog {</p> <pre><code>public void Search( string systemName, string searchType, string query, string resultCount, string ipAddress ) { LogSearch Manager = new LogSearch(); Manager.ProcessWcfRequest( systemName, searchType, query, resultCount, ipAddress); } </code></pre> <p>}</p> <p>These params are obviously not getting through. I've also tried inspecting <strong>System.Web.HttpContext.Current</strong> and <strong>WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters</strong> at runtime, and these don't contain the params either.</p> <p>I'm making the request using the following AJAX request:</p> <pre><code>jQuery.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "/Api/Rest/Log/Search", dataType: "json", data: { systemName : "test", searchType : "test", query : "test", resultCount : "test", ipAddress : "test" }, success: function (msg) { console.log(msg); } }); </code></pre> <p>So to re-iterate, the request is going through and I can hit breakpoints in my Service, meaning any service methods which require no params are fine, however for those that do require params, none are passed. </p> <p>Can anyone see where I'm going wrong?</p>
    singulars
    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.
    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