Note that there are some explanatory texts on larger screens.

plurals
  1. POFileTransfer to WCF Service receiving 405
    primarykey
    data
    text
    <p>I'm working on a mobile app using PhoneGap, and one of the features involves uploading an image to a web service for processing. I've written a WCF service that's hosted in IIS to accept the image, with a contract that looks like the following:</p> <pre><code>[ServiceContract] public interface IImages { [OperationContract(Name="UploadImage")] [WebInvoke(UriTemplate = "?file_key={fileKey}", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)] ImageResource UploadImage(string fileKey, Stream imageStream); } </code></pre> <p>The configuration section in my web.config looks like:</p> <pre><code> &lt;system.serviceModel&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"&gt; &lt;serviceActivations&gt; &lt;add service="Services.Images" relativeAddress="images.svc" /&gt; &lt;/serviceActivations&gt; &lt;/serviceHostingEnvironment&gt; &lt;services&gt; &lt;service behaviorConfiguration="DefaultServiceBehavior" name="Services.Images"&gt; &lt;endpoint behaviorConfiguration="DefaultEndpointBehavior" binding="webHttpBinding" bindingConfiguration="PublicStreamBinding" contract="Services.Contracts.IImages" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;bindings&gt; &lt;webHttpBinding&gt; &lt;binding name="PublicStreamBinding" maxReceivedMessageSize="2000000000" transferMode="Streamed"&gt; &lt;security mode="None" /&gt; &lt;/binding&gt; &lt;/webHttpBinding&gt; &lt;/bindings&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="DefaultEndpointBehavior"&gt; &lt;webHttp helpEnabled="true" /&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="DefaultServiceBehavior"&gt; &lt;serviceMetadata httpGetEnabled="false" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt; &lt;serviceThrottling maxConcurrentCalls="30" maxConcurrentInstances="30" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; </code></pre> <p>When I attempt to upload a file to the endpoint, using PhoneGap's FileTransfer class, the response returned from the service is a 405 Method Not Allowed. What am I doing wrong here?</p> <p><strong>UPDATE:</strong> The function in my mobile app that's uploading the file is below. This code previous worked fine when pointed to an older ASMX service.</p> <pre><code> ns.UploadImage = function(){ //alert(ns.Dictionary['LocalImagePath']); var uri = ns.Dictionary['LocalImagePath']; try { var options = new FileUploadOptions(); options.fileKey = uri.substr(uri.lastIndexOf('/')+1) + ".jpeg"; options.fileName = uri.substr(uri.lastIndexOf('/')+1) + ".jpeg"; options.mimeType = "image/jpeg"; var ft = new FileTransfer(); ft.upload(uri, GetServerUrl()+"images.svc?file_key="+options.fileKey, ns.UploadImageSuccess, ns.UploadImageError, options); } catch (e) { ns.UploadImageError(e); } }; </code></pre>
    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.
 

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