I am facing some problem in WCF Restful web service .
I have an Image and I am sending it to database from Android Application 1st converting Image into base64 string with 10,000 characters through Application.
In wcf reconvert base64 string in to real image and then send image into Db.
The issue is that when I am sending base64 long character string to WCF. WCF reject it and too long string error received Error 414.
I already used Post and Get both methods and also increase buffer size but same error all time received.
Same method when I apply in .asmx soap web service their each image insert successfully
You need to check your service buffer setting in binding configuration.If you are working with default one then update it.
Related
I am working on an ASP.Net core application where one of the actions is responsible to upload large files. The Limits.MaxRequestBodySize property is set to 100MB in the Startup.cs for Kestrel. The action that uploads the file is already decorated with [DisableRequestSizeLimit] and [RequestFormLimits(MultipartBodyLengthLimit = int.MaxValue)].
Despite ignoring the limit at action level and setting the maximum body size to 100MB at global level, the request fails with 500: BadHttpRequestException "Request body too large" when the file I am trying to upload is only 34MB. The exception occurs in one of the middleware at "await context.Request.Body.CopyToAsync(stream)". And the exception stack trace also mentions the Content-length is 129MB. The exception does not occur if I set the Limits.MaxRequestBodySize to 200MB or to null.
Questions:
Why is the request size 129MB when I am uploading only 34MB file? what makes the remaining ~100MB?
When the request is already in context.Request.Body, why is it throwing error while copying it ("await context.Request.Body.CopyToAsync(stream)")to a new stream?
I really appreciate any help with these. Please let me know if anything is unclear, I can provide more details.
Regards,
Siva
The issue could be that the default request limit in you application or the webserver is to low. Looks like the default maxAllowedContentLength is approx. 30MB.
Perhaps these link can help you out:
https://stackoverflow.com/a/59840618/432074
https://github.com/dotnet/aspnetcore/issues/20369#issuecomment-607057822
here is the solution:
There was nothing wrong with the MaxRequestBodySize or maxAllowedContentLength. It was the size of the request that was causing the issue. Eventhough I was uploading file size of ~34MB, the file was converted to byte array and then to base64. This resulted in increased request size. I used IFormFile interface to send the file instead of byte array/base64, it is working fine now.
We all are know some time we will get 500 error while trying to hit wcf url. for example if pass string value to integer parameter it will throw 500 error as request error. my question is how to log, this kind error in some file? because this will not reach our actual end point class coding right? so how to log this error in some file?
Any Help?
Assuming you want to log these on the server size, you should configure WCF tracing and use SvcTraceViewer to analyze the logs. More details on MSDN: http://msdn.microsoft.com/en-us/library/ms732023.aspx.
I may very well be wrong here - but if the client is supplying the wrong parameters to a web method, that would be a 404 as no method matches the incoming request?
I would say it's the clients job to send the right data to the right function, and to handle failures appropriately (an EndPointNotFoundException perhaps)
I am writing a iOS client for a an existing product that uses a legacy SOAP webservice. I got the proper URL to send my SOAP/XML messages too and even have some samples. However, none of them seem to work...
I always get a 404 error with the following error text "Predicate mismatch for View"
I am using an ASIFormDataRequest for the actual request and apending the data (SOAP XML in this case) via [someFormRequest appenData:myData].
I am flat out of ideas here and am wondering what, if anything I am doing wrong. Or should I ping one of the back end guys? Could this error be a result of something on the server side?
This is an error message spit out by the pyramid web framework when attempting to access a URL without supplying all of the required parameters. You definitely want to double check that the URL you are using has all of the required params (headers, query string options, request body, etc) and if you're convinced that what you are sending is correct then but your backend guys because it's definitely a miscommunication or a bug between the two of you.
I have an application to upload files to a server. I am using nettcpbinding and wshttpbinding. When the files is larger than 200 MB, I get a memory exception. Working around this, I have seen people recommend streaming, and of course it works with nettcpbinding for large files (>1GB), but when using wshttpbinding, what would be the approach?? Should I change to basichttpbinding?? what?? Thanks.
I suggest you expose another end point just to upload such large size data. This can have a binding that supports streaming. In our previous project we needed to do file uploads to server as part of business process. We ended up creating 2 endpoints one just dedicated to file upload, and another for all other business functionality.
The streaming data service can be a generic service to stream any data to the server and maybe return a token for identifying the data on server.For subsequent requests this token can be passed along to manipulate the data on server.
If you don't want to (or cannot because of legit reasons) change the binding nor use streaming, what you can do is have some method with a signature along the lines of the following:
void UploadFile(string fileName, long offset, byte[] data)
Instead of sending the whole file, you send little packets, and tell where the data should be placed. You can add more data, of course, like the whole filesize, CRC of the file to know if the transfer was successful, etc.
I have WCF service that returns an object that contains an array of bytes that can be saved as a PDF (my .NET component of this implementation works like a charm, the bytes are saved to a stream and they write out the PDF without issue). I can modify the WCF to return just the bytes if necessary. My question is: How can I get those bytes to the asp page so I can save them. I've spent several hours searching the web for methods/help/hints/anything, but have been relatively unsuccessful. I have a method for writing files in asp, but it takes an array of bytes, but I dont know how to get the bytes from the WCF. The only way I've been able to communicate with WCF is to use SOAP type calls and parse the XML that is returned (which is fine for the rest of the page, since I just need the text values that are returned), but this one needs the bytes returned to save the file. (And no, the WCF cannot save the file on its own, it lives on a different server and does not have access to share a drive map or something like that).
Any thoughts/hints/tips/etc would be GREATLY appreciated, Im going insane with this project!
Thanks in advance everyone!
It sounds like you are calling the WCF service and getting a string in return, if not see Calling WCF service by VBScript.
Once you have the string, convert it to a byte sub type(using ChrB()) and save it to a file or write it out to the client.
I found this code sample at Create and work with binary data in ASP/VBScript:
Function StringToMultiByte(S)
Dim i, MultiByte
For i=1 To Len(S)
MultiByte = MultiByte & ChrB(Asc(Mid(S,i,1)))
Next
StringToMultiByte = MultiByte
End Function