Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC0689340 for ; Tue, 13 Mar 2012 20:16:51 +0000 (UTC) Received: (qmail 1263 invoked by uid 500); 13 Mar 2012 20:16:51 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 1233 invoked by uid 500); 13 Mar 2012 20:16:51 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 1224 invoked by uid 99); 13 Mar 2012 20:16:51 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Mar 2012 20:16:51 +0000 Received: from localhost (HELO mail-yw0-f51.google.com) (127.0.0.1) (smtp-auth username wspeirs, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Mar 2012 20:16:51 +0000 Received: by yhnn12 with SMTP id n12so996359yhn.10 for ; Tue, 13 Mar 2012 13:16:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.7.200 with SMTP id l8mr8957977oea.52.1331669809885; Tue, 13 Mar 2012 13:16:49 -0700 (PDT) Received: by 10.182.148.10 with HTTP; Tue, 13 Mar 2012 13:16:49 -0700 (PDT) In-Reply-To: References: Date: Tue, 13 Mar 2012 16:16:49 -0400 Message-ID: Subject: Re: Setting SOAPAction in HTTPPost header From: William Speirs To: HttpClient User Discussion Content-Type: multipart/alternative; boundary=e89a8f83a5bbf9f20c04bb258982 --e89a8f83a5bbf9f20c04bb258982 Content-Type: text/plain; charset=ISO-8859-1 Setting the params of the client is not what you want. You want to set a header in the request. Something more like: request.setHeader("SOAPAction", "mySOAPAction"); // [1] [1] http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/message/AbstractHttpMessage.html#setHeader(java.lang.String, java.lang.String) Bill- On Tue, Mar 13, 2012 at 4:10 PM, Xue, Xiaohui wrote: > Hi All, > > I'm sending a SOAP request that requires to set a SOAPAction header. > Below is my code that I thought being correct. However, my WebServices > server keeps on telling me that there's no SOAP Action.. > > I have tried in Fiddler to compose the same request, and by putting > SOAPAction header in the composer, the server is able to return me the > correct answer. > Is my code of setup SOAPAction header not correct? Please note that I'm > using HTTPClient 4.0.3. > > Any helps are welcome. > > Thanks! > Xiaohui > > My code: > HttpClient httpClient = new DefaultHttpClient(); > httpClient.getParams().setParameter("Content-Type", > "text/xml; charset=utf-8"); > httpClient.getParams().setParameter("SOAPAction", > "mySOAPAction"); > > String body = mySOAPBody"; > StringEntity requestBody = new StringEntity(body, "utf-8"); > requestBody.setContentType(new BasicHeader("Content-Type", > "text/xml")); > > HttpPost request = new HttpPost(url); > request.setEntity(requestBody); > HttpResponse response = httpClient.execute(httpHost, > request); > > Server response: > xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPActionno > SOAPAction header!CRDB-DBSERVER > > > > --e89a8f83a5bbf9f20c04bb258982--