tags:

views:

23

answers:

2

I am using a third party Web Service. I am passing a string to a function in that service, that string, which i am reading from a UTF-8 text file. The problem it that the string contain some non ASCII characters.

Now if i save that text file to ANSI format, read it in a string and pass that string to Service then it works smoothly but with UTF-8 encoded string the service throw exception "The request failed with HTTP status 400: Bad Request."

Long story short

  1. NON ASCII characters
  2. UTF-8 encoding
  3. SOAP

I am using ASP.NET.

A: 

The sample client-side code that you tried with UTF-8 string being passed to the 3d-party web service call, was implemented using an ASP.NET web page/UI or something non-visual (i.e. a simple console C# program?). In other words, I'd like to know whether the content of the UTF-8 file is directly loaded at the server-side (in your ASP.NET) code or you are passing the content from an HTTP client-side context first (using HTTP POST/Upload).

If you are doing it directly, without involving an HTTP web browser, then it may be that that web service implementation might not accept UTF-8 encodings for that string arg. Try doing the same with another ws client (using a different language/platform such as C++ or Perl). This will confirm whether the ws implementation is ok with accepting UTF-8.

The 3rd party service is in Java. The content of the UTF-8 file is at my server side. Other the this third party service i also made a web service in .net and try to pass string(UTF-8 content) to it, but there is still issue.
Sakhawat Ali
A: 

Doing some further investigation to this issue i found that form feed(\f) and some other special characters are causing the problem. Actually I am extracting text from Word document, and with that text some special characters also come along.

Anyway for temporary purpose I did some string manipulation and replaced those special characters.

This temporary is work for now but I am looking for standard solution if there is any.

Waiting for you repose, thanks in advance

Sakhawat Ali