我有以下合同:
[OperationContract(Name = "Upload")]
[WebInvoke(Method = "POST", UriTemplate = "/Upload/{step}/{fileName}",
BodyStyle= WebMessageBodyStyle.WrappedRequest)]
Response FileUpload(string fileName, string step, Stream fileStream);
并执行:
public Response FileUpload(string fileName, string step, Stream fileStream)
{
FileStream fileToUpload = new FileStream("C:\inetpub\wwwroot\Upload\" + fileName, FileMode.Create);
byte[] bytearray = new byte[10000];
int bytesRead, totalBytesRead = 0;
do
{
bytesRead = fileStream.Read(bytearray, 0, bytearray.Length);
totalBytesRead += bytesRead;
} while (bytesRead > 0);
fileToUpload.Write(bytearray, 0, bytearray.Length);
fileToUpload.Close();
fileToUpload.Dispose();
Response res = new Response();
res.Successful = true;
res.Comment = "Bla bla";
return res;
}
并配置:
bindingConfiguration="StreamHTTP"
contract="BillboardServices.IBillboardService"
/>
transferMode="StreamedRequest"
maxReceivedMessageSize="10000000"
maxBufferSize="1000"
/>
当我通过Android http请求调用该方法时,我收到状态代码400-错误的请求.
我在同一Web服务上还有其他方法正在起作用.
我只是不知道问题出在哪里.