Hi I'm trying to post a Uint8Array from angular javascript client to wcf service. The problem is that when the array arrives at the service it is null. On the client end I've tried changing the array to different types (int8, int16 etc..) and also not stringifying the data, but in all cases when it arrives at the service it is null. On the service side I've tried to change the BodyStyle of the interface from Wrapped to Bare, but got a 500 error. I've also made changes to web config parameters, but I think web config is ok, because the post is actually making it to the method.
Any ideas what could be the problem? ultimately I'm trying to post an image from webcam on ipad or laptop to wcf service for input into sql server. My code is below
Thanks
Pete
//ANGULAR post to WCF
const data = new Uint8Array(8);
data[0] = 26;
let body:any = JSON.stringify(data);// body = '{"0":26,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0}'
let headers = {'Access-Control-Allow-Credentials':'false',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'DELETE, POST, GET, OPTIONS, PUT',
'Access-Control-Allow-Headers': 'application/json',
'Content-Type':'application/json'}
this.http.post(GlobalConstants.UploadServiceURL + "UploadPhotoDB", body, {'headers':headers}).subscribe(data => {
console.log(data);// null
})
WCF SERVICE
//Method
public byte[] UploadPhotoDB(byte[] input){//input is null
return input;
}
//Interface
[OperationContract(Name = "UploadPhotoDB")]
[DataContractFormat]
[WebInvoke(Method = "POST",
UriTemplate = "UploadPhotoDB/",
BodyStyle = WebMessageBodyStyle.Wrapped,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json
),
]
byte[] UploadPhotoDB(byte[] input);
//Applicable parts of WebConfig
<service name="SARIService.ServiceUpload" behaviorConfiguration="ServiceBehavior">
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="webHttpBindingConfig"
contract="SARIService.IServiceUpload"
behaviorConfiguration="web">
</endpoint>
</service>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<bindings>
<webHttpBinding>
<binding
maxBufferSize="999999" maxReceivedMessageSize="999999" />
<binding name="webHttpBindingConfig"
maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" transferMode="Streamed" sendTimeout="00:05:00">
<!-- <security mode="Transport"/>-->
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>