Author: ffang
Date: Fri Jun 4 09:29:05 2010
New Revision: 951338
URL: http://svn.apache.org/viewvc?rev=951338&view=rev
Log:
[SMXCOMP-748]CXF-BC consumer should not use DOM when using the JBI wrapper
Added:
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/StaxJbiWrapper.java
Modified:
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
Modified:
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
URL:
http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java?rev=951338&r1=951337&r2=951338&view=diff
==============================================================================
---
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
(original)
+++
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
Fri Jun 4 09:29:05 2010
@@ -52,6 +52,7 @@ import org.apache.cxf.staxutils.DepthXML
import org.apache.cxf.staxutils.PartialXMLStreamReader;
import org.apache.cxf.staxutils.StaxUtils;
import org.apache.servicemix.soap.util.DomUtil;
+import org.apache.servicemix.soap.util.stax.StaxSource;
/**
* @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
@@ -106,104 +107,118 @@ public class JbiInWsdl1Interceptor exten
document.appendChild(document.importNode(body, true));
}
}
+ message.setContent(Source.class, new DOMSource(document));
} else {
+ try {
+ XMLStreamReader reader = new StaxJbiWrapper(message);
+ message.setContent(Source.class, new StaxSource(reader));
+ } catch (UnsupportedOperationException e) {
+ document = createDOMWrapper(message);
+ if (document != null) {
+ message.setContent(Source.class, new DOMSource(document));
+ }
+ }
+ }
+
+ }
- BindingOperationInfo wsdlOperation = getOperation(message);
- BindingMessageInfo wsdlMessage = !isRequestor(message) ?
wsdlOperation
- .getInput()
- : wsdlOperation.getOutput();
-
- document = DomUtil.createDocument();
- Element root = DomUtil.createElement(document,
- CxfJbiConstants.WSDL11_WRAPPER_MESSAGE);
- String typeNamespace = wsdlMessage.getMessageInfo().getName()
- .getNamespaceURI();
- if (typeNamespace == null || typeNamespace.length() == 0) {
- throw new IllegalArgumentException(
- "messageType namespace is null or empty");
- }
- root.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":"
- + CxfJbiConstants.WSDL11_WRAPPER_MESSAGE_PREFIX,
- typeNamespace);
-
- root.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":"
- + CxfJbiConstants.WSDL11_WRAPPER_XSD_PREFIX,
- XMLConstants.W3C_XML_SCHEMA_NS_URI);
-
- root.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":"
- + CxfJbiConstants.WSDL11_WRAPPER_XSI_PREFIX,
- XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
-
- String typeLocalName = wsdlMessage.getMessageInfo().getName()
- .getLocalPart();
- if (typeLocalName == null || typeLocalName.length() == 0) {
- throw new IllegalArgumentException(
- "messageType local name is null or empty");
- }
- root.setAttribute(CxfJbiConstants.WSDL11_WRAPPER_TYPE,
- CxfJbiConstants.WSDL11_WRAPPER_MESSAGE_PREFIX + ":"
- + typeLocalName);
- String messageName = wsdlMessage.getMessageInfo().getName()
- .getLocalPart();
- root.setAttribute(CxfJbiConstants.WSDL11_WRAPPER_NAME,
messageName);
- root.setAttribute(CxfJbiConstants.WSDL11_WRAPPER_VERSION, "1.0");
-
- SoapBindingInfo binding = (SoapBindingInfo) message.getExchange()
- .get(Endpoint.class).getEndpointInfo().getBinding();
- String style = binding.getStyle(wsdlOperation.getOperationInfo());
- if (style == null) {
- style = binding.getStyle();
- }
-
- Element body = getBodyElement(message);
- if (body == null) {
- return;
- }
-
- if (body.getLocalName().equals("Fault")) {
- handleJBIFault(message, body);
- return;
- }
- List<SoapHeaderInfo> headers = wsdlMessage
- .getExtensors(SoapHeaderInfo.class);
- List<Header> headerElement = message.getHeaders();
- List<Object> parts = new ArrayList<Object>();
- for (MessagePartInfo part : wsdlMessage.getMessageParts()) {
- if ("document".equals(style)) {
- parts.add(body);
- } else /* rpc-style */ {
- // SOAP:Body element is the operation name, children are
- // operation parameters
-
- Element param = DomUtil.getFirstChildElement(body);
- boolean found = false;
- while (param != null) {
- if (part.getName().getLocalPart().equals(
- param.getLocalName())) {
- found = true;
- parts.add(wrapNodeList(param.getChildNodes()));
- break;
- }
- param = DomUtil.getNextSiblingElement(param);
- }
- if (!found) {
- throw new Fault(new Exception("Missing part '"
- + part.getName() + "'"));
+ private Document createDOMWrapper(SoapMessage message) {
+ Document document;
+ BindingOperationInfo wsdlOperation = getOperation(message);
+ BindingMessageInfo wsdlMessage = !isRequestor(message) ? wsdlOperation
+ .getInput()
+ : wsdlOperation.getOutput();
+
+ document = DomUtil.createDocument();
+ Element root = DomUtil.createElement(document,
+ CxfJbiConstants.WSDL11_WRAPPER_MESSAGE);
+ String typeNamespace = wsdlMessage.getMessageInfo().getName()
+ .getNamespaceURI();
+ if (typeNamespace == null || typeNamespace.length() == 0) {
+ throw new IllegalArgumentException(
+ "messageType namespace is null or empty");
+ }
+ root.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":"
+ + CxfJbiConstants.WSDL11_WRAPPER_MESSAGE_PREFIX,
+ typeNamespace);
+
+ root.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":"
+ + CxfJbiConstants.WSDL11_WRAPPER_XSD_PREFIX,
+ XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+ root.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":"
+ + CxfJbiConstants.WSDL11_WRAPPER_XSI_PREFIX,
+ XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
+
+ String typeLocalName = wsdlMessage.getMessageInfo().getName()
+ .getLocalPart();
+ if (typeLocalName == null || typeLocalName.length() == 0) {
+ throw new IllegalArgumentException(
+ "messageType local name is null or empty");
+ }
+ root.setAttribute(CxfJbiConstants.WSDL11_WRAPPER_TYPE,
+ CxfJbiConstants.WSDL11_WRAPPER_MESSAGE_PREFIX + ":"
+ + typeLocalName);
+ String messageName = wsdlMessage.getMessageInfo().getName()
+ .getLocalPart();
+ root.setAttribute(CxfJbiConstants.WSDL11_WRAPPER_NAME, messageName);
+ root.setAttribute(CxfJbiConstants.WSDL11_WRAPPER_VERSION, "1.0");
+
+ SoapBindingInfo binding = (SoapBindingInfo) message.getExchange()
+ .get(Endpoint.class).getEndpointInfo().getBinding();
+ String style = binding.getStyle(wsdlOperation.getOperationInfo());
+ if (style == null) {
+ style = binding.getStyle();
+ }
+
+ Element body = getBodyElement(message);
+ if (body == null) {
+ return null;
+ }
+
+ if (body.getLocalName().equals("Fault")) {
+ handleJBIFault(message, body);
+ return null;
+ }
+ List<SoapHeaderInfo> headers = wsdlMessage
+ .getExtensors(SoapHeaderInfo.class);
+ List<Header> headerElement = message.getHeaders();
+ List<Object> parts = new ArrayList<Object>();
+ for (MessagePartInfo part : wsdlMessage.getMessageParts()) {
+ if ("document".equals(style)) {
+ parts.add(body);
+ } else /* rpc-style */ {
+ // SOAP:Body element is the operation name, children are
+ // operation parameters
+
+ Element param = DomUtil.getFirstChildElement(body);
+ boolean found = false;
+ while (param != null) {
+ if (part.getName().getLocalPart().equals(
+ param.getLocalName())) {
+ found = true;
+ parts.add(wrapNodeList(param.getChildNodes()));
+ break;
}
+ param = DomUtil.getNextSiblingElement(param);
}
- }
- processHeader(message, headers, headerElement, parts);
- for (Object part : parts) {
- if (part instanceof Node) {
- addPart(root, (Node) part);
- } else if (part instanceof NodeList) {
- addPart(root, (NodeList) part);
- } else if (part instanceof SoapHeader) {
- addPart(root, (Node) ((SoapHeader) part).getObject());
+ if (!found) {
+ throw new Fault(new Exception("Missing part '"
+ + part.getName() + "'"));
}
}
}
- message.setContent(Source.class, new DOMSource(document));
+ processHeader(message, headers, headerElement, parts);
+ for (Object part : parts) {
+ if (part instanceof Node) {
+ addPart(root, (Node) part);
+ } else if (part instanceof NodeList) {
+ addPart(root, (NodeList) part);
+ } else if (part instanceof SoapHeader) {
+ addPart(root, (Node) ((SoapHeader) part).getObject());
+ }
+ }
+ return document;
}
private void processHeader(SoapMessage message,
Added:
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/StaxJbiWrapper.java
URL:
http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/StaxJbiWrapper.java?rev=951338&view=auto
==============================================================================
---
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/StaxJbiWrapper.java
(added)
+++
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/StaxJbiWrapper.java
Fri Jun 4 09:29:05 2010
@@ -0,0 +1,557 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicemix.cxfbc.interceptors;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.binding.soap.model.SoapHeaderInfo;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
+import org.apache.cxf.staxutils.PartialXMLStreamReader;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.servicemix.soap.util.stax.ExtendedXMLStreamReader;
+import org.apache.servicemix.soap.util.stax.FragmentStreamReader;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+
+public class StaxJbiWrapper implements XMLStreamReader {
+ public static final int STATE_START_DOC = 0;
+ public static final int STATE_START_ELEMENT_WRAPPER = 1;
+ public static final int STATE_START_ELEMENT_PART = 2;
+ public static final int STATE_RUN_PART = 3;
+ public static final int STATE_END_ELEMENT_PART = 4;
+ public static final int STATE_END_ELEMENT_WRAPPER = 5;
+ public static final int STATE_END_DOC = 6;
+
+ private BindingMessageInfo wsdlMessage;
+ private int state = STATE_START_DOC;
+ private int part = -1;
+ private int reader = -1;
+ private int event = START_DOCUMENT;
+ private List<List<XMLStreamReader>> parts = new
ArrayList<List<XMLStreamReader>>();
+
+ public StaxJbiWrapper(Message message) {
+ BindingOperationInfo wsdlOperation = getOperation(message);
+ wsdlMessage = !isRequestor(message) ? wsdlOperation.getInput() :
wsdlOperation.getOutput();
+ XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
+ if (isRequestor(message)) {
+ throw new UnsupportedOperationException();
+ }
+ List<SoapHeaderInfo> headers = wsdlMessage
+ .getExtensors(SoapHeaderInfo.class);
+ if (headers != null && headers.size() > 0) {
+ throw new UnsupportedOperationException();
+ }
+ SoapBindingInfo binding = (SoapBindingInfo) message.getExchange()
+ .get(Endpoint.class).getEndpointInfo().getBinding();
+ String style = binding.getStyle(wsdlOperation.getOperationInfo());
+ if (style == null) {
+ style = binding.getStyle();
+ }
+ int nbBodyParts = 0;
+ for (MessagePartInfo part : wsdlMessage.getMessageParts()) {
+ if (nbBodyParts++ > 0) {
+ throw new UnsupportedOperationException();
+ }
+ if ("document".equals(style)) {
+ parts.add(Collections.<XMLStreamReader>singletonList(new
FragmentStreamReader(xmlReader)));
+ } else /* rpc-style */ {
+ throw new UnsupportedOperationException();
+ }
+ }
+ }
+
+ public int getEventType() {
+ return event;
+ }
+
+ public int next() throws XMLStreamException {
+ switch (state) {
+ case STATE_START_DOC:
+ state = STATE_START_ELEMENT_WRAPPER;
+ event = START_ELEMENT;
+ break;
+ case STATE_START_ELEMENT_WRAPPER:
+ if (parts.size() > 0) {
+ state = STATE_START_ELEMENT_PART;
+ event = START_ELEMENT;
+ part = 0;
+ reader = 0;
+ } else {
+ state = STATE_END_ELEMENT_WRAPPER;
+ event = END_ELEMENT;
+ }
+ break;
+ case STATE_START_ELEMENT_PART:
+ if (reader >= parts.get(part).size()) {
+ state = STATE_END_ELEMENT_PART;
+ event = END_ELEMENT;
+ } else {
+ state = STATE_RUN_PART;
+ event = parts.get(part).get(reader).next();
+ if (event == START_DOCUMENT) {
+ event = parts.get(part).get(reader).next();
+ }
+ }
+ break;
+ case STATE_RUN_PART:
+ event = parts.get(part).get(reader).next();
+ if (event == END_DOCUMENT) {
+ if (++reader >= parts.get(part).size()) {
+ state = STATE_END_ELEMENT_PART;
+ event = END_ELEMENT;
+ } else {
+ event = parts.get(part).get(reader).next();
+ if (event == START_DOCUMENT) {
+ event = parts.get(part).get(reader).next();
+ }
+ }
+ }
+ break;
+ case STATE_END_ELEMENT_PART:
+ if (++part >= parts.size()) {
+ state = STATE_END_ELEMENT_WRAPPER;
+ event = END_ELEMENT;
+ } else {
+ state = STATE_START_ELEMENT_PART;
+ event = START_ELEMENT;
+ reader = 0;
+ }
+ break;
+ case STATE_END_ELEMENT_WRAPPER:
+ case STATE_END_DOC:
+ state = STATE_END_DOC;
+ event = END_DOCUMENT;
+ break;
+ }
+ return event;
+ }
+
+ public QName getName() {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ case STATE_END_ELEMENT_WRAPPER:
+ return CxfJbiConstants.WSDL11_WRAPPER_MESSAGE;
+ case STATE_START_ELEMENT_PART:
+ case STATE_END_ELEMENT_PART:
+ return CxfJbiConstants.WSDL11_WRAPPER_PART;
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getName();
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getLocalName() {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ case STATE_END_ELEMENT_WRAPPER:
+ return CxfJbiConstants.WSDL11_WRAPPER_MESSAGE_LOCALNAME;
+ case STATE_START_ELEMENT_PART:
+ case STATE_END_ELEMENT_PART:
+ return CxfJbiConstants.WSDL11_WRAPPER_PART_LOCALNAME;
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getLocalName();
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespaceURI() {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ case STATE_END_ELEMENT_WRAPPER:
+ case STATE_START_ELEMENT_PART:
+ case STATE_END_ELEMENT_PART:
+ return CxfJbiConstants.WSDL11_WRAPPER_NAMESPACE;
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getNamespaceURI();
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getPrefix() {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ case STATE_END_ELEMENT_WRAPPER:
+ case STATE_START_ELEMENT_PART:
+ case STATE_END_ELEMENT_PART:
+ return CxfJbiConstants.WSDL11_WRAPPER_PREFIX;
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getPrefix();
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public boolean hasName() {
+ return state == STATE_RUN_PART ?
parts.get(part).get(reader).isStartElement() : (event == START_ELEMENT || event
== END_ELEMENT);
+ }
+
+ public Object getProperty(String s) throws IllegalArgumentException {
+ return null; //To change body of implemented methods use File |
Settings | File Templates.
+ }
+
+ public void require(int i, String s, String s1) throws XMLStreamException {
+ //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getElementText() throws XMLStreamException {
+ return null; //To change body of implemented methods use File |
Settings | File Templates.
+ }
+
+ public int nextTag() throws XMLStreamException {
+ while (hasNext()) {
+ int e = next();
+ if (e == START_ELEMENT || e == END_ELEMENT)
+ return e;
+ }
+ return event;
+ }
+
+ public boolean hasNext() throws XMLStreamException {
+ return event != END_DOCUMENT;
+ }
+
+ public void close() throws XMLStreamException {
+ //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getNamespaceURI(String s) {
+ return null; //To change body of implemented methods use File |
Settings | File Templates.
+ }
+
+ public boolean isStartElement() {
+ return state == STATE_RUN_PART ?
parts.get(part).get(reader).isStartElement() : event == START_ELEMENT;
+ }
+
+ public boolean isEndElement() {
+ return state == STATE_RUN_PART ?
parts.get(part).get(reader).isEndElement() : event == END_ELEMENT;
+ }
+
+ public boolean isCharacters() {
+ return state == STATE_RUN_PART ?
parts.get(part).get(reader).isCharacters() : event == CHARACTERS;
+ }
+
+ public boolean isWhiteSpace() {
+ return state == STATE_RUN_PART ?
parts.get(part).get(reader).isWhiteSpace() : event == SPACE;
+ }
+
+ public String getAttributeValue(String s, String s1) {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public int getAttributeCount() {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ return 6;
+ case STATE_START_ELEMENT_PART:
+ return 0;
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getAttributeCount();
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public QName getAttributeName(int i) {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ switch (i) {
+ case 0: return new
QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+ CxfJbiConstants.WSDL11_WRAPPER_MESSAGE_PREFIX,
+ XMLConstants.XMLNS_ATTRIBUTE);
+ case 1: return new
QName(CxfJbiConstants.WSDL11_WRAPPER_TYPE);
+ case 2: return new
QName(CxfJbiConstants.WSDL11_WRAPPER_NAME);
+ case 3: return new
QName(CxfJbiConstants.WSDL11_WRAPPER_VERSION);
+ case 4: return new
QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+ CxfJbiConstants.WSDL11_WRAPPER_XSI_PREFIX,
+ XMLConstants.XMLNS_ATTRIBUTE);
+ case 5: return new
QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+ CxfJbiConstants.WSDL11_WRAPPER_XSD_PREFIX,
+ XMLConstants.XMLNS_ATTRIBUTE);
+ default: throw new IllegalStateException();
+ }
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getAttributeName(i);
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeNamespace(int i) {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ switch (i) {
+ case 0: return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+ case 1:
+ case 2:
+ case 3: return XMLConstants.NULL_NS_URI;
+ case 4: return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+ case 5: return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+ default: throw new IllegalStateException();
+ }
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getAttributeNamespace(i);
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeLocalName(int i) {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ switch (i) {
+ case 0: return
CxfJbiConstants.WSDL11_WRAPPER_MESSAGE_PREFIX;
+ case 1: return CxfJbiConstants.WSDL11_WRAPPER_TYPE;
+ case 2: return CxfJbiConstants.WSDL11_WRAPPER_NAME;
+ case 3: return CxfJbiConstants.WSDL11_WRAPPER_VERSION;
+ case 4: return CxfJbiConstants.WSDL11_WRAPPER_XSI_PREFIX;
+ case 5: return CxfJbiConstants.WSDL11_WRAPPER_XSD_PREFIX;
+ default: throw new IllegalStateException();
+ }
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getAttributeLocalName(i);
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributePrefix(int i) {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ switch (i) {
+ case 0: return XMLConstants.XMLNS_ATTRIBUTE;
+ case 1:
+ case 2:
+ case 3: return XMLConstants.DEFAULT_NS_PREFIX;
+ case 4: return XMLConstants.XMLNS_ATTRIBUTE;
+ case 5: return XMLConstants.XMLNS_ATTRIBUTE;
+ default: throw new IllegalStateException();
+ }
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getAttributePrefix(i);
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeType(int i) {
+ return "CDATA";
+ }
+
+ public String getAttributeValue(int i) {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ switch (i) {
+ case 0:
+ {
+ String typeNamespace =
wsdlMessage.getMessageInfo().getName().getNamespaceURI();
+ if (typeNamespace == null || typeNamespace.length() ==
0) {
+ throw new IllegalArgumentException("messageType
namespace is null or empty");
+ }
+ return typeNamespace;
+ }
+ case 1:
+ {
+ String typeLocalName =
wsdlMessage.getMessageInfo().getName().getLocalPart();
+ if (typeLocalName == null || typeLocalName.length() ==
0) {
+ throw new IllegalArgumentException("messageType
local name is null or empty");
+ }
+ return CxfJbiConstants.WSDL11_WRAPPER_MESSAGE_PREFIX +
":" + typeLocalName;
+ }
+ case 2:
+ return
wsdlMessage.getMessageInfo().getName().getLocalPart().toString();
+ case 3:
+ return "1.0";
+ case 4:
+ return XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+ case 5:
+ return XMLConstants.W3C_XML_SCHEMA_NS_URI;
+ default: throw new IllegalStateException();
+ }
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getAttributeValue(i);
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public int getNamespaceCount() {
+ switch (state) {
+ case STATE_START_ELEMENT_WRAPPER:
+ case STATE_END_ELEMENT_WRAPPER:
+ case STATE_START_ELEMENT_PART:
+ case STATE_END_ELEMENT_PART:
+ return 0;
+ case STATE_RUN_PART:
+ return parts.get(part).get(reader).getNamespaceCount();
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespacePrefix(int i) {
+ return parts.get(part).get(reader).getNamespacePrefix(i);
+ }
+
+ public String getNamespaceURI(int i) {
+ return parts.get(part).get(reader).getNamespaceURI(i);
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ if (state == STATE_RUN_PART) {
+ return parts.get(part).get(reader).getNamespaceContext();
+ } else {
+ return new ExtendedXMLStreamReader.SimpleNamespaceContext();
+ }
+ }
+
+ public String getText() {
+ if (state == STATE_RUN_PART) {
+ return parts.get(part).get(reader).getText();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public char[] getTextCharacters() {
+ if (state == STATE_RUN_PART) {
+ return parts.get(part).get(reader).getTextCharacters();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws
XMLStreamException {
+ if (state == STATE_RUN_PART) {
+ return parts.get(part).get(reader).getTextCharacters(i, chars, i1,
i2);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextStart() {
+ if (state == STATE_RUN_PART) {
+ return parts.get(part).get(reader).getTextStart();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextLength() {
+ if (state == STATE_RUN_PART) {
+ return parts.get(part).get(reader).getTextLength();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getEncoding() {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean hasText() {
+ if (state == STATE_RUN_PART) {
+ return parts.get(part).get(reader).hasText();
+ } else {
+ return false;
+ }
+ }
+
+ public Location getLocation() {
+ return new Location() {
+ public int getCharacterOffset() {
+ return 0;
+ }
+ public int getColumnNumber() {
+ return 0;
+ }
+ public int getLineNumber() {
+ return 0;
+ }
+ public String getPublicId() {
+ return null;
+ }
+ public String getSystemId() {
+ return null;
+ }
+ };
+ }
+
+ public String getVersion() {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean isStandalone() {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean standaloneSet() {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public String getCharacterEncodingScheme() {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public String getPITarget() {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public String getPIData() {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ private BindingOperationInfo getOperation(Message message) {
+ BindingOperationInfo operation = message.getExchange().get(
+ BindingOperationInfo.class);
+ if (operation == null) {
+ throw new Fault(
+ new Exception("Operation not bound on this message"));
+ }
+ return operation;
+ }
+
+ private boolean isRequestor(Message message) {
+ return Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE));
+ }
+}
\ No newline at end of file