Android Question Stuck in a web service

hatzisn

Well-Known Member
Licensed User
Longtime User
Hi everyone,

I am trying to post a pretty long json string (almost 2600 characters long) to asp.net back end and I get an error that the string was truncated and it is not full to be parsed. I googled it and I found some solutions at the internet which none of it worked. I tried it both in on-line IIS and local ASP.NET Development Center. To try it in local server I ran Fiddler and created a redirection in the Hosts from a virtual host called from the phone to the localhost as the local ASP.NET development server does not allow connections from other computers in order to test your code. I got the same errror. I thought Ok since it is this way and one cannot face its own destiny continueslly I will try it with a web service and post the string to the web service. Both in on-line IIS and local ASP.NET Development Server I get the 400 Bad Request response as I see in fiddler and in B4A just bad request. This is getting on my nurves. Any help will be highly appreciated.

Thanks
 

MarkusR

Well-Known Member
Licensed User
Longtime User
you send post as content type json?

B4X:
Job.PostString("http://www.abc/test" , data )
Job.GetRequest.SetContentType("application/json") 'need okhttp lib
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Hi Markus,

Here is the web service specifications (URL masked):

POST /gwserv.asmx HTTP/1.1
Host: xxxxxxx.xxxxxx.gr
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://xxxxxxx.xxxxxx.gr/groupp"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<groupp xmlns="https://xxxxxxx.xxxxxx.gr/">
<json>string</json>

</groupp>
</soap:Body>
</soap:Envelope>



Here is the code that calls it:

B4X:
hj.PostString("https://xxxxxxx.xxxxxx.gr/gwserv.asmx", BuildRequest(CommonFunctions2.Template, sJson))
hj.GetRequest.SetContentType("text/xml; charset=utf-8")
hj.GetRequest.SetHeader("SOAPAction", """https://xxxxxxx.xxxxxx.gr/groupp""")

The CommonFunctions2.Template returns the lines seen green above and the BuildRequest function replaces the blue "string" seen above with a very long JSon (greater than 2500 characters long). The answer was 400 bad request.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
So a short string works and a long string gives you a 400 error code?
 
Upvote 0
Top