org.apache.ode.axis2.httpbinding
Class HttpMethodConverter

java.lang.Object
  extended by org.apache.ode.axis2.httpbinding.HttpMethodConverter

public class HttpMethodConverter
extends java.lang.Object


Field Summary
protected  javax.wsdl.Binding binding
           
protected  javax.wsdl.Definition definition
           
protected static Messages msgs
           
protected  java.lang.String portName
           
protected  javax.xml.namespace.QName serviceName
           
 
Constructor Summary
HttpMethodConverter(javax.wsdl.Definition definition, javax.xml.namespace.QName serviceName, java.lang.String portName)
           
 
Method Summary
 org.apache.commons.httpclient.HttpMethod createHttpRequest(PartnerRoleMessageExchange odeMex, org.apache.commons.httpclient.params.HttpParams params)
           
 org.apache.commons.httpclient.HttpMethod createHttpRequest(PartnerRoleMessageExchange odeMex, org.apache.commons.httpclient.params.HttpParams params, java.lang.String baseUrl)
           
 org.w3c.dom.Element createPartElement(javax.wsdl.Part part, org.w3c.dom.Element receivedElement)
          Create the element to be associated with this part into the Message.
 org.w3c.dom.Element createPartElement(javax.wsdl.Part part, java.lang.String textContent)
          Create the element to be associated with this part into the Message.
 void extractHttpResponseHeaders(Message odeMessage, org.apache.commons.httpclient.HttpMethod method, javax.wsdl.Operation operationDef)
          Process the HTTP Response Headers.
protected  java.util.Map<java.lang.String,org.w3c.dom.Element> extractPartElements(javax.wsdl.Message msgDef, org.w3c.dom.Element message)
           
 java.lang.Object[] parseFault(PartnerRoleMessageExchange odeMex, org.apache.commons.httpclient.HttpMethod method)
           
 void parseHttpResponse(Message odeResponse, org.apache.commons.httpclient.HttpMethod method, javax.wsdl.Operation opDef)
           
protected  org.apache.commons.httpclient.HttpMethod prepareHttpMethod(javax.wsdl.BindingOperation opBinding, java.lang.String verb, java.util.Map<java.lang.String,org.w3c.dom.Element> partValues, java.util.Map<java.lang.String,org.w3c.dom.Node> headers, java.lang.String rootUri, org.apache.commons.httpclient.params.HttpParams params)
          create and initialize the http method.
 void setHttpRequestHeaders(org.apache.commons.httpclient.HttpMethod method, javax.wsdl.BindingOperation opBinding, java.util.Map<java.lang.String,org.w3c.dom.Element> partValues, java.util.Map<java.lang.String,org.w3c.dom.Node> headers, org.apache.commons.httpclient.params.HttpParams params)
          First go through the list of default headers set in the method params.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msgs

protected static final Messages msgs

definition

protected javax.wsdl.Definition definition

binding

protected javax.wsdl.Binding binding

serviceName

protected javax.xml.namespace.QName serviceName

portName

protected java.lang.String portName
Constructor Detail

HttpMethodConverter

public HttpMethodConverter(javax.wsdl.Definition definition,
                           javax.xml.namespace.QName serviceName,
                           java.lang.String portName)
Method Detail

createHttpRequest

public org.apache.commons.httpclient.HttpMethod createHttpRequest(PartnerRoleMessageExchange odeMex,
                                                                  org.apache.commons.httpclient.params.HttpParams params)
                                                           throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

createHttpRequest

public org.apache.commons.httpclient.HttpMethod createHttpRequest(PartnerRoleMessageExchange odeMex,
                                                                  org.apache.commons.httpclient.params.HttpParams params,
                                                                  java.lang.String baseUrl)
                                                           throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

prepareHttpMethod

protected org.apache.commons.httpclient.HttpMethod prepareHttpMethod(javax.wsdl.BindingOperation opBinding,
                                                                     java.lang.String verb,
                                                                     java.util.Map<java.lang.String,org.w3c.dom.Element> partValues,
                                                                     java.util.Map<java.lang.String,org.w3c.dom.Node> headers,
                                                                     java.lang.String rootUri,
                                                                     org.apache.commons.httpclient.params.HttpParams params)
                                                              throws java.io.UnsupportedEncodingException
create and initialize the http method. Http Headers that may been passed in the params are not set in this method. Headers will be automatically set by HttpClient. See usages of HostParams.DEFAULT_HEADERS See org.apache.commons.httpclient.HttpMethodDirector#executeMethod(org.apache.commons.httpclient.HttpMethod)

Throws:
java.io.UnsupportedEncodingException

setHttpRequestHeaders

public void setHttpRequestHeaders(org.apache.commons.httpclient.HttpMethod method,
                                  javax.wsdl.BindingOperation opBinding,
                                  java.util.Map<java.lang.String,org.w3c.dom.Element> partValues,
                                  java.util.Map<java.lang.String,org.w3c.dom.Node> headers,
                                  org.apache.commons.httpclient.params.HttpParams params)
First go through the list of default headers set in the method params. This param is then remove to avoid interference with HttpClient. Actually the default headers should be overriden by any headers set from the process. Not to mention that, for a given header, HttpClient do not overwrite any previous values but simply append the default value.
See org.apache.commons.httpclient.params.HostParams.DEFAULT_HEADERS

Then go through the list of message headers and set them if empty.

Finally go through the list of Namespaces.ODE_HTTP_EXTENSION_NS:header elements included in the input binding. For each of them, set the HTTP Request Header with the static value defined by the attribute Namespaces.ODE_HTTP_EXTENSION_NS:value, or the part value mentioned in the attribute Namespaces.ODE_HTTP_EXTENSION_NS:part.

Finally, set the 'Accept' header if the output content type of the operation exists.

Notice that the last header value overrides any values set previoulsy. Meaning that message headers might get overriden by parts bound to headers.


extractPartElements

protected java.util.Map<java.lang.String,org.w3c.dom.Element> extractPartElements(javax.wsdl.Message msgDef,
                                                                                  org.w3c.dom.Element message)

createPartElement

public org.w3c.dom.Element createPartElement(javax.wsdl.Part part,
                                             java.lang.String textContent)
Create the element to be associated with this part into the Message.
An element named with the part name will be returned. the content of this element depends on the part.

If the part has a non-null element name, a new element will be created and named accordingly then the text value is inserted in this new element.
else the given text content is simply set on the part element.

Parameters:
part -
textContent -
Returns:
an element named with the part name will be returned

createPartElement

public org.w3c.dom.Element createPartElement(javax.wsdl.Part part,
                                             org.w3c.dom.Element receivedElement)
Create the element to be associated with this part into the Message.

If the part has a non-null element name, the bodyElement is simply appended. Else if the bodyElement has a text content, the value is set to the message. Else append all nodes of bodyElement to the returned element. Attributes are ignored.

The name of the returned element is the part name.

Parameters:
part -
receivedElement -
Returns:
the element to insert "as is" to ODE message

extractHttpResponseHeaders

public void extractHttpResponseHeaders(Message odeMessage,
                                       org.apache.commons.httpclient.HttpMethod method,
                                       javax.wsdl.Operation operationDef)
Process the HTTP Response Headers.

First go through the list of Namespaces.ODE_HTTP_EXTENSION_NS:header elements included in the output binding. For each of them, set the header value as the value of the message part.

Then add all HTTP headers as header part in the message. The name of the header would be the part name.

Finally, insert a header names 'Status-Line'. This header contains an element as returned by HttpHelper.statusLineToElement(String) .

Parameters:
odeMessage -
method -
operationDef -

parseHttpResponse

public void parseHttpResponse(Message odeResponse,
                              org.apache.commons.httpclient.HttpMethod method,
                              javax.wsdl.Operation opDef)
                       throws java.lang.Exception
Throws:
java.lang.Exception

parseFault

public java.lang.Object[] parseFault(PartnerRoleMessageExchange odeMex,
                                     org.apache.commons.httpclient.HttpMethod method)