0

I have a strange issue and I dont know how to debug it.

I need to make a POST SOAP request to a WebService server.

My Java code is:

    String urlParameters = "<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
..................
</soap:Body>
</soap:Envelope>";
        URL url;
        HttpURLConnection connection = null;  
        try {
        //Create connection
        url = new URL(targetURL);
        connection = (HttpURLConnection)url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
        connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
        connection.setRequestProperty("SOAPAction", "http://xxxxx/Foo" );

        connection.setUseCaches (false);
        connection.setDoInput(true);
        connection.setDoOutput(true);

        //Send request
        DataOutputStream wr = new DataOutputStream (connection.getOutputStream ());
        wr.writeBytes (urlParameters);
        wr.flush ();
        wr.close ();

        //Get Response  
          InputStream is = connection.getInputStream();
          BufferedReader rd = new BufferedReader(new InputStreamReader(is));
          String line;
          StringBuilder response = new StringBuilder(); 
          while((line = rd.readLine()) != null) {
            response.append(line);
            response.append('\r');
          }
          rd.close();

Now if the urlParameters is less than or equal 1308 bytes then it works fine and I can get the response. However if the length exceeds 1308 bytes( i.e. if I add one more character to the string ), then it wont work( it seems not even get out of the client machine, it never reaches the server )

I tried with soapUI and it also gives me the same issue. I'm running on Ubuntu 12.04

Yes i do have the same problem with CURL. Here is the output if the request length is valid:

* About to connect() to epermit port 8085 (#0)
*   Trying 192.168.14.100... connected
> POST /xxx/xxx.asmx HTTP/1.1
> User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: xxx:8085
> Accept: */*
> Content-Type:text/xml; charset=utf-8
> SOAPAction:"xxxxx"
> Content-Length: 1304
> Expect: 100-continue
> 
< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Cache-Control: private, max-age=0
< Content-Type: text/xml; charset=utf-8
< Server: Microsoft-IIS/7.5
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< Date: Thu, 28 Mar 2013 03:52:55 GMT
< Content-Length: 324
< 
* Connection #0 to host epermit left intact
* Closing connection #0
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><xxxx xmlns="xxxxxxx" /></soap:Body></soap:Envelope>

And when I make the request bigger than 1308 bytes:

* About to connect() to xxxxxxxxxxx port 8085 (#0)
*   Trying 192.168.14.100... connected
> POST /xxxxxxx/xxxxxxx.asmx HTTP/1.1
> User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: xxxxxxxx:8085
> Accept: */*
> Content-Type:text/xml; charset=utf-8
> SOAPAction:"xxxxxxxxxxxxxxxxx"
> Content-Length: 1309
> Expect: 100-continue
> 
< HTTP/1.1 100 Continue

Any idea for this?

thanks,

VB4EVA
  • 81
  • 2
  • 17
  • Should be a server limit. Duplicated of http://stackoverflow.com/questions/2880722/is-http-post-limitless/2880766#2880766 and others... just make a search. – DiogoSantana Mar 28 '13 at 03:10
  • I guess that's not the case, because I tried with Fiddler2 on a Windows machine and it just works fine with a request bigger than 1308bytes. This is more on the client-side configuration I guess but I dont know where to check it. – VB4EVA Mar 28 '13 at 03:13
  • 1
    Do you have access to the server? You are possibly overflowing into another ethernet frame and the server is not handling it well. – BevynQ Mar 28 '13 at 03:14
  • Is any data being sent over the wire? – BevynQ Mar 28 '13 at 03:15
  • 1
    I don't have a linux here, so I can't test. What server application are you using? Maybe this could help: http://stackoverflow.com/questions/2943477/is-there-a-max-size-for-post-parameter-content – DiogoSantana Mar 28 '13 at 03:20
  • I have the access to the server( I need to be VPNed to it ). As mentioned, if the request length is smaller than 1308 bytes, I can see the response back. What do you mean by overflowing into another ethernet frame and the server is not handling it well? thanks. By the way, I'm using wireless network to do this. – VB4EVA Mar 28 '13 at 03:22
  • @DiogoSantana The server application uses C# but it is our customer and not handled by us. I dont see why 1308bytes is considered as too big. thanks. – VB4EVA Mar 28 '13 at 03:26
  • 1
    Do you get the same results with `wget` or `curl`? – tc. Mar 28 '13 at 03:34
  • Yes i do have the same problem with CURL. See my edited question: – VB4EVA Mar 28 '13 at 03:54
  • 1
    @user1726452 : data gets sent along the network in a series of packets. These packets have a size <= the MTU of the network this is usually some number below 1500 octets. I suspect the server is getting two of these packets and only reading the first one. It is then having a failure trying to parse the incomplete data. – BevynQ Apr 01 '13 at 23:00
  • I tried to fiddle with the MTU but it does not solve the problem. Note that Fiddler2 on Windows works fine( I can send a large request and get the response back), so it's very indicative that the problem is not on the server side. Now i will try to port my Java app to Windows see if it works. – VB4EVA Apr 02 '13 at 03:12
  • I tried my Java app on Windows and I'm able to send a much larger request( 46728 bytes ) and it just works fine. So I doubt it's my Ubuntu OS environment, which causes the problem but I dont know what should I check? – VB4EVA Apr 02 '13 at 03:42
  • @BevynQ actually your guess is correct. When I changed the MTU size from 1500 to a smaller number i.e. 1300 ( or 576 ) it actually works. Should I infer that there is still some configuration issue on the server side? How come I can't set a random MTU and it just works? – VB4EVA Apr 02 '13 at 04:35
  • and how can I mark your comment as an answer? – VB4EVA Apr 02 '13 at 04:54

1 Answers1

0

Data gets sent along the network in a series of packets. These packets have a size <= the MTU of the network this is usually some number below 1500 octets. I suspect the server is getting two of these packets and only reading the first one. It is then having a failure trying to parse the incomplete data.

BevynQ
  • 8,089
  • 4
  • 25
  • 37