Turning Off the Chunked HTTP Flag

This section provides a tutorial example on how to turn off the Chunked HTTP flag to fix the 'Transport error: 411 Error: Length Required' error.

To fix the error with Axis2 1.4.1, "org.apache.axis2.AxisFault: Transport error: 411 Error: Length Required", I searched the Internet and found a suggestion of using option.setProperty(HTTPConstants.CHUNKED,false).

Here is my second test program, Axis2ServiceClientChunked.java:

/* Axis2ServiceClientChunked.java
 * Copyright (c) 2009 HerongYang.com. All Rights Reserved.
import java.io.PrintStream;
import java.net.URL;
import javax.xml.namespace.QName;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.Options;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axiom.om.OMElement;
class Axis2ServiceClientChunked {
   public static void main(String[] args) {
      PrintStream out = System.out;

// Setting initial values
      String server = "https://www.herongyang.com/Service/";
      String wsdl = server+"Hello_WSDL_11_SOAP.wsdl";
      String tns = "https://www.herongyang.com/Service/";
      String serviceName = "helloService";
      String portName = "helloPort";

      try {
         ServiceClient client = new ServiceClient(null,
            new URL(wsdl), new QName(tns, serviceName), portName);

// Fixing org.apache.axis2.AxisFault: Transport error:
//    411 Error: Length Required
         Options option = client.getOptions();

         OMElement request = null;
         OMElement response = client.sendReceive(
      new QName(tns, "Hello"), request);
      } catch (Exception e) {

Execution of this program is described below:

herong> java -cp .;\local\axis2\lib\* Axis2ServiceClientChunked

<hy:HelloResponse xmlns:hy="https://www.herongyang.com/Service/">
      Hello from server - herongyang.com.

Cool. The output tells me:

Table of Contents

 About This Book

 Introduction to WSDL 2.0

 WSDL 2.0 Document Structure and Syntax

 WSDL Version 2.0 Part 2: Adjuncts

 WSDL 2.0 Document Examples with SOAP Binding

 Using WSDL Document in Java Apache Axis2/Java for WSDL

 Apache Woden for WSDL Documents in Java

 SoapUI - Web Service Testing Tool

 PHP SOAP Extension for WSDL

 Perl SOAP::Lite for WSDL

 Introduction to WSDL 1.1

 WSDL 1.1 Document Structure and Syntax

 WSDL 1.1 Binding Extension for SOAP 1.1

 SoapUI as WSDL 1.1 Testing Tool

 WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles

 PHP SOAP Extension for WSDL 1.1

 Perl SOAP::Lite for WSDL 1.1

Apache Axis2/Java for WSDL 1.1

 Creating Service Client with WSDL 1.1 Document

 org.apache.axis2.client.Options - Operation Client Options

 sendReceive() Method - Invoking a Named Operation

Turning Off the Chunked HTTP Flag

 AXIOM (AXIs Object Model)

 Axis2RegistrationClient.java - document/literal Style

 org.apache.axis2.rpc.client.RPCServiceClient Class

 Axis2GetExchangeRateClient.java - rpc/encoded Style

 SocketRequestResponseServer.java - Socket Server Testing Program

 Capturing the HTTP Request from an Axis2 Client Program

 Using WSDL2Java to Generate Web Service Stub Classes

 WSDL 1.1 Binding Extension for SOAP 1.2

 WSDL 1.1 and SOAP 1.2 Examples - Document and RPC Styles

 SOAP 1.2 Binding - PHP, Java and Perl Clients

 Python SOAP Client: Zeep

 WSDL Related Terminologies

 Archived Tutorials


 Full Version in PDF/EPUB