axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Takayoshi Fujiki (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AXIS2-1014) org.apache.asix2.saaj.SOAPConnectionImpl does not handle MimeHeaders (SOAPAction)
Date Thu, 10 Jul 2008 16:58:33 GMT

    [ https://issues.apache.org/jira/browse/AXIS2-1014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612572#action_12612572
] 

Takayoshi Fujiki commented on AXIS2-1014:
-----------------------------------------

Hi,

Although, I'm not submitter but I have same problem with Axis2 now. Could someone give me
comment on this?

I downloaded rev.675563 Axis2 source codes from svn, and tried the following code with it.
(This also occurs with Axis2 1.4)

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;

public class Axis2SoapTest {
	public static void main(String[] args) {
		try {
			MessageFactory mfactory = MessageFactory.newInstance();
			SOAPMessage message = mfactory.createMessage();
			message.getSOAPHeader().detachNode();

			SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
			envelope.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");

			MimeHeaders headers = message.getMimeHeaders();
			headers.setHeader("SOAPAction", "\"urn:myUrn#myAction\"");

			SOAPBody body = message.getSOAPBody();
			body.addBodyElement(new QName("urn:myUrn", "myAction", "u"));

			SOAPConnectionFactory cfactory = SOAPConnectionFactory.newInstance();
			SOAPConnection connection = cfactory.createConnection();
			connection.call(message, new URL("http://10.3.10.13:55247/"));
			connection.close();
		} catch(SOAPException e) {
			e.printStackTrace();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
}

But this code sends the following request to the server. SOAPAction header was "urn:anonOutInOp".("urn:myUrn#myAction"
is expected.)
It seems that call() method still did not see MimeHeaders.

POST / HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "urn:anonOutInOp"
User-Agent: Axis2
Host: 10.3.10.13:55247
Transfer-Encoding: chunked

c4
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><u:myAction
xmlns:u="urn:myUrn" /></soapenv:Body></soapenv:Envelope>
0

FYI, the above code works properly with JDK default library.
POST / HTTP/1.1
Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
SOAPAction: "urn:myUrn#myAction"
Content-Type: text/xml; charset=utf-8
Content-Length: 229
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.6.0_06
Host: 10.3.10.13:55247
Connection: keep-alive

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><u:myAction
xmlns:u="urn:myUrn"/></SOAP-ENV:Body></SOAP-ENV:Envelope>

Thanks in advance.


> org.apache.asix2.saaj.SOAPConnectionImpl does not handle MimeHeaders (SOAPAction)
> ---------------------------------------------------------------------------------
>
>                 Key: AXIS2-1014
>                 URL: https://issues.apache.org/jira/browse/AXIS2-1014
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: client-api
>            Reporter: Jian Wu
>            Assignee: sumedha rubasinghe
>
> I looked into org.apache.axis2.saaj.SOAPConnectionImpl.java in the
> Axis2 Source Repositoy, as the following code snippet shown, it
> never pass down MimeHeaders from SOAPMessage to the ServiceClient,
> so all the SOAPMessages  with empty SOAPAction as ""
> ==========================================
>     public SOAPMessage call(SOAPMessage request, Object endpoint) throws SOAPException
{
>         if (closed) {
>             throw new SOAPException("SOAPConnection closed");
>         }
>         // initialize URL
>         URL url;
>         try {
>             url = (endpoint instanceof URL) ? (URL) endpoint : new URL(endpoint.toString());
>         } catch (MalformedURLException e) {
>             throw new SOAPException(e);
>         }
>         // initialize and set Options
>         Options options = new Options();
>         options.setTo(new EndpointReference(url.toString()));
>         // initialize the Sender
>         OperationClient opClient;
>         try {
>             serviceClient = new ServiceClient();
>             opClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
>         } catch (AxisFault e) {
>             throw new SOAPException(e);
>         }
>         opClient.setOptions(options);
>         if (request.countAttachments() != 0) { // SOAPMessage with attachments
>             opClient.getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,
>                                               Constants.VALUE_TRUE);
>             return handleSOAPMessage(request, opClient);
>         } else { // simple SOAPMessage
>             return handleSOAPMessage(request, opClient);
>         }
>     }
> private SOAPMessage handleSOAPMessage(SOAPMessage request,
>                                           OperationClient opClient) throws SOAPException
{
>         MessageContext requestMsgCtx = new MessageContext();
>         try {
>             requestMsgCtx.setEnvelope(toOMSOAPEnvelope(request));
>             opClient.addMessageContext(requestMsgCtx);
>             opClient.execute(true);
>             MessageContext msgCtx = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>             //TODO: get attachments
>             return getSOAPMessage(msgCtx.getEnvelope());
>         } catch (AxisFault e) {
>             throw new SOAPException(e);
>         }
>     }
> protected org.apache.axiom.soap.SOAPEnvelope toOMSOAPEnvelope(SOAPMessage saajSOAPMsg)
>             throws SOAPException {
>         final org.apache.axiom.soap.SOAPEnvelope omSOAPEnv =
>                 SAAJUtil.toOMSOAPEnvelope(saajSOAPMsg.getSOAPPart().getDocumentElement());
>         System.err.println("#### req OM Soap Env=" + omSOAPEnv);
>         Map attachmentMap = new HashMap();
>         final Iterator attachments = saajSOAPMsg.getAttachments();
>         while (attachments.hasNext()) {
>             final AttachmentPart attachment = (AttachmentPart) attachments.next();
>             if (attachment.getContentId() == null ||
>                 attachment.getContentId().trim().length() == 0) {
>                 attachment.setContentId(IDGenerator.generateID());
>             }
>             if (attachment.getDataHandler() == null) {
>                 throw new SOAPException("Attachment with NULL DataHandler");
>             }
>             attachmentMap.put(attachment.getContentId(), attachment);
>         }
>         insertAttachmentNodes(attachmentMap, omSOAPEnv);
> //        printOMSOAPEnvelope(omSOAPEnv);
>         return omSOAPEnv;
>     }
> ====================================== 
> As suggested by Davanum Srinivas, I file this bug to track this problem

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message