[jboss-jira] [JBoss JIRA] (AS7-4201) Cannot be cast org.apache.cxf.jaxws.context.WrappedMessageContext to javax.xml.ws.handler.soap.SOAPMessageContext

Will Tatam (JIRA) jira-events at lists.jboss.org
Tue Oct 16 13:05:01 EDT 2012


    [ https://issues.jboss.org/browse/AS7-4201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12726940#comment-12726940 ] 

Will Tatam commented on AS7-4201:
---------------------------------

Our soap client send an extra header that contains the REMOTE_ADDR of the user who is browsing the website back to the application server. This is used so the web service can pass the website visitor's ip address to the bank for anti-fraud checks. The code below worked fine in AS5. When I made this bug report we had axis1 bundled in with our ear. I have not yet re-tested since we replaced axis with jaxws for consuming third party web services

@Stateless
@WebService
public class MyClass implements MyInterface {

	public String testMethod() {
		return "Call came from " + getVisitorIp();
	}


	private String getVisitorIp() {
		try {
			SOAPMessageContext jaxwsContext = (SOAPMessageContext) wsContext.getMessageContext();
			if(jaxwsContext == null) {
				logger.warn("getVisitorIp() SOAPMessageContext is NULL");
				return null;
			}
			SOAPHeader soapHeader = jaxwsContext.getMessage().getSOAPHeader();
			if(soapHeader == null) {
				logger.warn("getVisitorIp() SOAPHeader is NULL");
				return null;
			}
			// Extract All header elements.
			Iterator headerElements = soapHeader.examineAllHeaderElements();
			while (headerElements.hasNext()) {
				 SOAPHeaderElement element = (SOAPHeaderElement) headerElements.next();
				logger.debug("soapHeader." + element.getElementName().getLocalName() + " = " + element.getValue());
				if(element.getElementName().getLocalName().equalsIgnoreCase("REMOTE_ADDR")) {
					ip = element.getValue();
				}
			}
		} catch (SOAPException se) {
			logger.error("Failed to parse SOAP Header", se);
		}
		return ip;
	}
}
                
> Cannot be cast org.apache.cxf.jaxws.context.WrappedMessageContext to javax.xml.ws.handler.soap.SOAPMessageContext
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: AS7-4201
>                 URL: https://issues.jboss.org/browse/AS7-4201
>             Project: Application Server 7
>          Issue Type: Bug
>          Components: Web Services
>    Affects Versions: 7.1.1.Final
>            Reporter: Will Tatam
>            Assignee: Alessio Soldano
>
> SOAPMessageContext jaxwsContext = (SOAPMessageContext) wsContext.getMessageContext();
> Caused by: java.lang.ClassCastException: org.apache.cxf.jaxws.context.WrappedMessageContext cannot be cast to javax.xml.ws.handler.soap.SOAPMessageContext
> This was working fine on AS 5.1.
> If I check the docs for WrappedMessageContext it's sub sclass is SOAPMessageContextImpl which does implement javax.xml.ws.handler.soap.SOAPMessageContext. See http://cxf.apache.org/javadoc/latest/org/apache/cxf/jaxws/context/WrappedMessageContext.html

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list