[jboss-cvs] JBossAS SVN: r73601 - in projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854: src/main/org/jboss/jaxr/juddi and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 22 16:52:21 EDT 2008
Author: darran.lofthouse at jboss.com
Date: 2008-05-22 16:52:20 -0400 (Thu, 22 May 2008)
New Revision: 73601
Modified:
projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/.classpath
projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/pom.xml
projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/src/main/org/jboss/jaxr/juddi/JUDDIServlet.java
Log:
[JBPAPP-854] Initial fixes.
Modified: projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/.classpath
===================================================================
--- projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/.classpath 2008-05-22 20:51:21 UTC (rev 73600)
+++ projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/.classpath 2008-05-22 20:52:20 UTC (rev 73601)
@@ -2,21 +2,19 @@
<classpath>
<classpathentry kind="src" path="src/main"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-mbeans/5.0-SNAPSHOT/jboss-mbeans-5.0-SNAPSHOT.jar"/>
<classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.8/log4j-1.2.8.jar"/>
<classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-xacml/sun-xacml/2.0/sun-xacml-2.0.jar"/>
<classpathentry kind="var" path="M2_REPO/jboss/jbossxb/jbossxb/1.0.1.TEST/jbossxb-1.0.1.TEST.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-j2ee/SNAPSHOT/jboss-j2ee-SNAPSHOT.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jnpserver/5.0-SNAPSHOT/jnpserver-5.0-SNAPSHOT.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-xacml/sunxacml-support/2.0/sunxacml-support-2.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-j2se/5.0-SNAPSHOT/jboss-j2se-5.0-SNAPSHOT.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
<classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.2.GA/jboss-common-core-2.0.2.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-system/5.0-SNAPSHOT/jboss-system-5.0-SNAPSHOT.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-javamail/mail/1.3.1/mail-1.3.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-transaction/5.0-SNAPSHOT/jboss-transaction-5.0-SNAPSHOT.jar"/>
- <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.4.GA/javassist-3.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-system/4.2.2.GA/jboss-system-4.2.2.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-scout/scout/0.7rc2/scout-0.7rc2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-j2ee/4.0.2/jboss-j2ee-4.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-jmx/4.0.4/jboss-jmx-4.0.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-saaj/1.0.4.GA/jboss-saaj-1.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/juddi/juddi/0.9RC4/juddi-0.9RC4.jar"/>
<classpathentry kind="output" path="output-eclipse/classes"/>
</classpath>
Modified: projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/pom.xml
===================================================================
--- projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/pom.xml 2008-05-22 20:51:21 UTC (rev 73600)
+++ projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/pom.xml 2008-05-22 20:52:20 UTC (rev 73601)
@@ -210,7 +210,7 @@
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-system</artifactId>
- <version>5.0-SNAPSHOT</version>
+ <version>4.2.2.GA</version>
</dependency>
<dependency>
<groupId>jboss</groupId>
Modified: projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/src/main/org/jboss/jaxr/juddi/JUDDIServlet.java
===================================================================
--- projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/src/main/org/jboss/jaxr/juddi/JUDDIServlet.java 2008-05-22 20:51:21 UTC (rev 73600)
+++ projects/jaxr/branches/jaxr-1.2.0.GA_JBPAPP-854/src/main/org/jboss/jaxr/juddi/JUDDIServlet.java 2008-05-22 20:52:20 UTC (rev 73601)
@@ -64,6 +64,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Iterator;
import java.util.Vector;
/**
@@ -74,328 +75,335 @@
*/
public class JUDDIServlet extends HttpServlet
{
- /** The serialVersionUID */
+ /** The serialVersionUID */
private static final long serialVersionUID = 8768916717023791095L;
// XML Document Builder
- private static DocumentBuilder docBuilder = null;
+ private static DocumentBuilder docBuilder = null;
- // jUDDI XML Handler maker
- private static HandlerMaker maker = HandlerMaker.getInstance();
+ // jUDDI XML Handler maker
+ private static HandlerMaker maker = HandlerMaker.getInstance();
- private static Logger log = Logger.getLogger(JUDDIServlet.class);
+ private static Logger log = Logger.getLogger(JUDDIServlet.class);
- /**
- *
- */
- public void doGet(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException
- {
- res.setHeader("Allow", "POST");
- res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The request " +
- "method 'GET' is not allowed by UDDI API.");
- }
+ /**
+ *
+ */
+ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
+ {
+ res.setHeader("Allow", "POST");
+ res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The request " + "method 'GET' is not allowed by UDDI API.");
+ }
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException
- {
- res.setContentType("text/xml; charset=utf-8");
+ public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
+ {
+ res.setContentType("text/xml; charset=utf-8");
- SOAPMessage soapReq = null;
- SOAPMessage soapRes = null;
+ SOAPMessage soapReq = null;
+ SOAPMessage soapRes = null;
- try
- {
- MessageFactory msgFactory = MessageFactory.newInstance();
- soapReq = msgFactory.createMessage(null, req.getInputStream());
- soapRes = msgFactory.createMessage();
- if(log.isDebugEnabled())
+ try
+ {
+ MessageFactory msgFactory = MessageFactory.newInstance();
+ soapReq = msgFactory.createMessage(null, req.getInputStream());
+ soapRes = msgFactory.createMessage();
+ if (log.isDebugEnabled())
+ {
+ ByteArrayOutputStream bs = new ByteArrayOutputStream();
+ soapReq.writeTo(bs);
+ log.debug("Request received::" + bs.toString());
+ }
+
+ SOAPBody soapReqBody = soapReq.getSOAPBody();
+ Iterator it = soapReqBody.getChildElements();
+ Element uddiReq = null;
+ while (uddiReq == null && it.hasNext())
+ {
+ Object current = it.next();
+ if (current instanceof Element)
{
- ByteArrayOutputStream bs = new ByteArrayOutputStream();
- soapReq.writeTo(bs);
- log.debug("Request received::"+bs.toString());
- }
+ uddiReq = (Element)current;
+ }
+ }
- SOAPBody soapReqBody = soapReq.getSOAPBody();
- Element uddiReq = (Element) soapReqBody.getFirstChild();
- if (uddiReq == null)
- throw new FatalErrorException("A UDDI request was not " +
- "found in the SOAP message.");
+ if (uddiReq == null)
+ throw new FatalErrorException("A UDDI request was not " + "found in the SOAP message.");
- String function = uddiReq.getLocalName();
- if ((function == null) || (function.trim().length() == 0))
- throw new FatalErrorException("The name of the UDDI request " +
- "could not be identified.");
- IHandler requestHandler = maker.lookup(function);
- if (requestHandler == null)
- throw new UnsupportedException("The UDDI request " +
- "type specified is unknown: " + function);
+ String function = uddiReq.getLocalName();
+ if ((function == null) || (function.trim().length() == 0))
+ throw new FatalErrorException("The name of the UDDI request " + "could not be identified.");
+ IHandler requestHandler = maker.lookup(function);
+ if (requestHandler == null)
+ throw new UnsupportedException("The UDDI request " + "type specified is unknown: " + function);
- String generic = uddiReq.getAttribute("generic");
- if (generic == null)
- throw new FatalErrorException("A UDDI generic attribute " +
- "value was not found for UDDI request: " + function + " (The " +
- "'generic' attribute must be present)");
- else if (!generic.equals(IRegistry.UDDI_V2_GENERIC))
- throw new UnsupportedException("Currently only UDDI v2 " +
- "requests are supported. The generic attribute value " +
- "received was: " + generic);
+ String generic = uddiReq.getAttribute("generic");
+ if (generic == null)
+ throw new FatalErrorException("A UDDI generic attribute " + "value was not found for UDDI request: " + function + " (The "
+ + "'generic' attribute must be present)");
+ else if (!generic.equals(IRegistry.UDDI_V2_GENERIC))
+ throw new UnsupportedException("Currently only UDDI v2 " + "requests are supported. The generic attribute value " + "received was: " + generic);
- // Unmarshal the raw xml into the appropriate jUDDI
- // request object.
+ // Unmarshal the raw xml into the appropriate jUDDI
+ // request object.
- RegistryObject uddiReqObj = requestHandler.unmarshal(uddiReq);
- if(uddiReqObj == null)
- throw new FatalErrorException("Uddi Request is null");
+ RegistryObject uddiReqObj = requestHandler.unmarshal(uddiReq);
+ if (uddiReqObj == null)
+ throw new FatalErrorException("Uddi Request is null");
- // Grab a reference to the shared jUDDI registry
- // instance (make sure it's running) and execute the
- // requested UDDI function.
+ // Grab a reference to the shared jUDDI registry
+ // instance (make sure it's running) and execute the
+ // requested UDDI function.
- RegistryObject uddiResObj = null;
- RegistryEngine registry = RegistryServlet.getRegistry();
- if ((registry != null) && (registry.isAvailable()))
- uddiResObj = registry.execute(uddiReqObj);
- else
- throw new BusyException("The Registry is currently unavailable.");
+ RegistryObject uddiResObj = null;
+ RegistryEngine registry = RegistryServlet.getRegistry();
+ if ((registry != null) && (registry.isAvailable()))
+ uddiResObj = registry.execute(uddiReqObj);
+ else throw new BusyException("The Registry is currently unavailable.");
- // Lookup the appropriate response handler which will
- // be used to marshal the UDDI object into the appropriate
- // xml format.
+ // Lookup the appropriate response handler which will
+ // be used to marshal the UDDI object into the appropriate
+ // xml format.
- IHandler responseHandler = maker.lookup(uddiResObj.getClass().getName());
- if (responseHandler == null)
- throw new FatalErrorException("The response object " +
- "type is unknown: " + uddiResObj.getClass().getName());
+ IHandler responseHandler = maker.lookup(uddiResObj.getClass().getName());
+ if (responseHandler == null)
+ throw new FatalErrorException("The response object " + "type is unknown: " + uddiResObj.getClass().getName());
- // Create a new 'temp' XML element to use as a container
- // in which to marshal the UDDI response data into.
+ // Create a new 'temp' XML element to use as a container
+ // in which to marshal the UDDI response data into.
- DocumentBuilder docBuilder = getDocumentBuilder();
- Document document = docBuilder.newDocument();
- Element element = document.createElement("temp");
+ DocumentBuilder docBuilder = getDocumentBuilder();
+ Document document = docBuilder.newDocument();
+ Element element = document.createElement("temp");
- // Lookup the appropriate response handler and marshal
- // the juddi object into the appropriate xml format (we
- // only support UDDI v2.0 at this time). Attach the
- // results to the body of the SOAP response.
+ // Lookup the appropriate response handler and marshal
+ // the juddi object into the appropriate xml format (we
+ // only support UDDI v2.0 at this time). Attach the
+ // results to the body of the SOAP response.
- responseHandler.marshal(uddiResObj, element);
- log.debug("Response that will be sent:");
- log.debug(XMLUtils.toString((Element) element.getFirstChild()));
+ responseHandler.marshal(uddiResObj, element);
+ log.debug("Response that will be sent:");
+ log.debug(XMLUtils.toString((Element)element.getFirstChild()));
- // Grab a reference to the 'temp' element's
- // only child here (this has the effect of
- // discarding the temp element) and append
- // this child to the soap response body
+ // Grab a reference to the 'temp' element's
+ // only child here (this has the effect of
+ // discarding the temp element) and append
+ // this child to the soap response body
- /*document.appendChild(element.getFirstChild());
- soapRes.getSOAPBody().addDocument(document);*/
- Element el = (Element) element.getFirstChild();
- soapRes = this.createSOAPMessage(el);
- } catch (Exception ex) // Catch ALL exceptions
- {
- // SOAP Fault values
- String faultCode = null;
- String faultString = null;
- String faultActor = null;
+ /*document.appendChild(element.getFirstChild());
+ soapRes.getSOAPBody().addDocument(document);*/
+ Element el = (Element)element.getFirstChild();
+ soapRes = this.createSOAPMessage(el);
+ }
+ catch (Exception ex) // Catch ALL exceptions
+ {
+ // SOAP Fault values
+ String faultCode = null;
+ String faultString = null;
+ String faultActor = null;
- // UDDI DispositionReport values
- String errno = null;
- String errCode = null;
- String errMsg = null;
+ // UDDI DispositionReport values
+ String errno = null;
+ String errCode = null;
+ String errMsg = null;
- if (ex instanceof RegistryException)
- {
+ if (ex instanceof RegistryException)
+ {
- log.error("RegistryException::",ex);
+ log.error("RegistryException::", ex);
- RegistryException rex = (RegistryException) ex;
+ RegistryException rex = (RegistryException)ex;
- faultCode = rex.getFaultCode(); // SOAP Fault faultCode
- faultString = rex.getFaultString(); // SOAP Fault faultString
- faultActor = rex.getFaultActor(); // SOAP Fault faultActor
+ faultCode = rex.getFaultCode(); // SOAP Fault faultCode
+ faultString = rex.getFaultString(); // SOAP Fault faultString
+ faultActor = rex.getFaultActor(); // SOAP Fault faultActor
- DispositionReport dispRpt = rex.getDispositionReport();
- if (dispRpt != null)
- {
- Result result = null;
- ErrInfo errInfo = null;
+ DispositionReport dispRpt = rex.getDispositionReport();
+ if (dispRpt != null)
+ {
+ Result result = null;
+ ErrInfo errInfo = null;
- Vector results = dispRpt.getResultVector();
- if ((results != null) && (!results.isEmpty()))
- result = (Result) results.elementAt(0);
+ Vector results = dispRpt.getResultVector();
+ if ((results != null) && (!results.isEmpty()))
+ result = (Result)results.elementAt(0);
- if (result != null)
- {
- errno = String.valueOf(result.getErrno()); // UDDI Result errno
- errInfo = result.getErrInfo();
+ if (result != null)
+ {
+ errno = String.valueOf(result.getErrno()); // UDDI Result errno
+ errInfo = result.getErrInfo();
- if (errInfo != null)
- {
- errCode = errInfo.getErrCode(); // UDDI ErrInfo errCode
- errMsg = errInfo.getErrMsg(); // UDDI ErrInfo errMsg
- }
- }
- }
- } else
- {
+ if (errInfo != null)
+ {
+ errCode = errInfo.getErrCode(); // UDDI ErrInfo errCode
+ errMsg = errInfo.getErrMsg(); // UDDI ErrInfo errMsg
+ }
+ }
+ }
+ }
+ else
+ {
- log.error(ex.getMessage(), ex);
+ log.error(ex.getMessage(), ex);
- faultCode = "Server";
- faultString = ex.getMessage();
- faultActor = null;
+ faultCode = "Server";
+ faultString = ex.getMessage();
+ faultActor = null;
+ errno = String.valueOf(Result.E_FATAL_ERROR);
+ errCode = Result.lookupErrCode(Result.E_FATAL_ERROR);
+ errMsg = Result.lookupErrText(Result.E_FATAL_ERROR);
+ }
- errno = String.valueOf(Result.E_FATAL_ERROR);
- errCode = Result.lookupErrCode(Result.E_FATAL_ERROR);
- errMsg = Result.lookupErrText(Result.E_FATAL_ERROR);
- }
+ try
+ {
+ SOAPBody soapResBody = soapRes.getSOAPBody();
+ SOAPFault soapFault = soapResBody.addFault();
- try
+ if (faultCode == null)
+ faultCode = "Unavailable";
+
+ if (faultCode.contains(":") == false)
{
- SOAPBody soapResBody = soapRes.getSOAPBody();
- SOAPFault soapFault = soapResBody.addFault();
- if(faultCode == null)
- faultCode = "Unavailable";
- soapFault.setFaultCode(faultCode);
- soapFault.setFaultString(faultString);
- soapFault.setFaultActor(faultActor);
+ faultCode = ((Node)soapResBody).getPrefix() + ":" + faultCode;
+ }
- Detail faultDetail = soapFault.addDetail();
+ soapFault.setFaultCode(faultCode);
+ soapFault.setFaultString(faultString);
+ soapFault.setFaultActor(faultActor);
- SOAPElement dispRpt = faultDetail.addChildElement("dispositionReport", "", IRegistry.UDDI_V2_NAMESPACE);
- dispRpt.setAttribute("generic", IRegistry.UDDI_V2_GENERIC);
- dispRpt.setAttribute("operator", Config.getOperator());
+ Detail faultDetail = soapFault.addDetail();
- SOAPElement result = dispRpt.addChildElement("result");
- result.setAttribute("errno", errno);
+ SOAPElement dispRpt = faultDetail.addChildElement("dispositionReport", "", IRegistry.UDDI_V2_NAMESPACE);
+ dispRpt.setAttribute("generic", IRegistry.UDDI_V2_GENERIC);
+ dispRpt.setAttribute("operator", Config.getOperator());
- SOAPElement errInfo = result.addChildElement("errInfo");
- errInfo.setAttribute("errCode", errCode);
- errInfo.setValue(errMsg);
- } catch (Exception e)
- { // if we end up in here it's just NOT good.
- log.error("A serious error has occured while assembling the SOAP Fault.", e);
- }
- } finally
- {
- try
+ SOAPElement result = dispRpt.addChildElement("result");
+ result.setAttribute("errno", errno);
+
+ SOAPElement errInfo = result.addChildElement("errInfo");
+ errInfo.setAttribute("errCode", errCode);
+ errInfo.setValue(errMsg);
+ }
+ catch (Exception e)
+ { // if we end up in here it's just NOT good.
+ log.error("A serious error has occured while assembling the SOAP Fault.", e);
+ }
+ }
+ finally
+ {
+ try
+ {
+ if (log.isDebugEnabled())
{
- if(log.isDebugEnabled())
- {
- ByteArrayOutputStream bs = new ByteArrayOutputStream();
- soapRes.writeTo(bs);
- log.debug("Response being sent::"+bs.toString());
- }
- soapRes.writeTo(res.getOutputStream());
- } catch (SOAPException sex)
- {
- log.error("SOAPException::",sex);
+ ByteArrayOutputStream bs = new ByteArrayOutputStream();
+ soapRes.writeTo(bs);
+ log.debug("Response being sent::" + bs.toString());
}
- }
- }
+ soapRes.writeTo(res.getOutputStream());
+ }
+ catch (SOAPException sex)
+ {
+ log.error("SOAPException::", sex);
+ }
+ }
+ }
- /**
- *
- */
- private DocumentBuilder getDocumentBuilder()
- {
- if (docBuilder == null)
- docBuilder = createDocumentBuilder();
- return docBuilder;
- }
+ /**
+ *
+ */
+ private DocumentBuilder getDocumentBuilder()
+ {
+ if (docBuilder == null)
+ docBuilder = createDocumentBuilder();
+ return docBuilder;
+ }
- /**
- *
- */
- private synchronized DocumentBuilder createDocumentBuilder()
- {
- if (docBuilder != null)
- return docBuilder;
+ /**
+ *
+ */
+ private synchronized DocumentBuilder createDocumentBuilder()
+ {
+ if (docBuilder != null)
+ return docBuilder;
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- //factory.setValidating(true);
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ //factory.setValidating(true);
- docBuilder = factory.newDocumentBuilder();
- } catch (ParserConfigurationException pcex)
- {
- log.error("ParserConfigurationException::",pcex);
- }
+ docBuilder = factory.newDocumentBuilder();
+ }
+ catch (ParserConfigurationException pcex)
+ {
+ log.error("ParserConfigurationException::", pcex);
+ }
- return docBuilder;
- }
-
- private SOAPMessage createSOAPMessage(Element elem) throws Exception
- {
- String prefix = "uddi";
- MessageFactory msgFactory = MessageFactory.newInstance();
- SOAPFactory factory = SOAPFactory.newInstance();
-
- SOAPMessage message = msgFactory.createMessage();
- message.getSOAPHeader().detachNode();
- SOAPPart soapPart = message.getSOAPPart();
- SOAPBody soapBody = soapPart.getEnvelope().getBody();
- //Create the outer body element
- String uddins = IRegistry.UDDI_V2_NAMESPACE;
- Name bodyName = factory.createName(elem.getNodeName(), prefix, uddins);
- SOAPBodyElement bodyElement = soapBody.addBodyElement(bodyName);
- bodyElement.addNamespaceDeclaration(prefix,uddins);
- appendAttributes(bodyElement, elem.getAttributes(), factory);
- appendElements(bodyElement,elem.getChildNodes(), factory);
- return message;
- }
-
- private void appendAttributes(SOAPElement bodyElement, NamedNodeMap nnm,
- SOAPFactory factory) throws SOAPException
- {
- int len = nnm != null ? nnm.getLength() : 0;
- for (int i = 0; i < len; i++)
- {
- Node n = nnm.item(i);
- String nodename = n.getNodeName();
- String nodevalue = n.getNodeValue();
- if("xmlns".equals(nodename))
- continue;
- //Special case: xml:lang
- if("xml:lang".equals(nodename))
- {
- Name xmlLang = factory.createName("lang","xml",
- "http://www.w3.org/TR/REC-xml/");
- bodyElement.addAttribute(xmlLang, nodevalue);
- }
- else
- bodyElement.addAttribute(factory.createName(nodename), nodevalue);
- }
- }
-
- private void appendElements(SOAPElement bodyElement, NodeList nlist,
- SOAPFactory factory)
- throws SOAPException
- {
- String prefix = "uddi";
- String uddins = IRegistry.UDDI_V2_NAMESPACE;
- int len = nlist != null ? nlist.getLength() : 0;
+ return docBuilder;
+ }
- for (int i = 0; i < len; i++)
- {
- Node node = nlist.item(i);
- short nodeType = node != null ? node.getNodeType() : -100;
- if (Node.ELEMENT_NODE == nodeType)
- {
- Element el = (Element)node;
- Name name = factory.createName(el.getNodeName(), prefix,uddins);
- SOAPElement attachedEl = bodyElement.addChildElement(name);
- appendAttributes(attachedEl, el.getAttributes(), factory);
- appendElements(attachedEl, el.getChildNodes(), factory);
- } else if (nodeType == Node.TEXT_NODE)
- {
- bodyElement.addTextNode(node.getNodeValue());
- }
- }
- }
+ private SOAPMessage createSOAPMessage(Element elem) throws Exception
+ {
+ String prefix = "uddi";
+ MessageFactory msgFactory = MessageFactory.newInstance();
+ SOAPFactory factory = SOAPFactory.newInstance();
+
+ SOAPMessage message = msgFactory.createMessage();
+ message.getSOAPHeader().detachNode();
+ SOAPPart soapPart = message.getSOAPPart();
+ SOAPBody soapBody = soapPart.getEnvelope().getBody();
+ //Create the outer body element
+ String uddins = IRegistry.UDDI_V2_NAMESPACE;
+ Name bodyName = factory.createName(elem.getNodeName(), prefix, uddins);
+ SOAPBodyElement bodyElement = soapBody.addBodyElement(bodyName);
+ bodyElement.addNamespaceDeclaration(prefix, uddins);
+ appendAttributes(bodyElement, elem.getAttributes(), factory);
+ appendElements(bodyElement, elem.getChildNodes(), factory);
+ return message;
+ }
+
+ private void appendAttributes(SOAPElement bodyElement, NamedNodeMap nnm, SOAPFactory factory) throws SOAPException
+ {
+ int len = nnm != null ? nnm.getLength() : 0;
+ for (int i = 0; i < len; i++)
+ {
+ Node n = nnm.item(i);
+ String nodename = n.getNodeName();
+ String nodevalue = n.getNodeValue();
+ if ("xmlns".equals(nodename))
+ continue;
+ //Special case: xml:lang
+ if ("xml:lang".equals(nodename))
+ {
+ Name xmlLang = factory.createName("lang", "xml", "http://www.w3.org/TR/REC-xml/");
+ bodyElement.addAttribute(xmlLang, nodevalue);
+ }
+ else bodyElement.addAttribute(factory.createName(nodename), nodevalue);
+ }
+ }
+
+ private void appendElements(SOAPElement bodyElement, NodeList nlist, SOAPFactory factory) throws SOAPException
+ {
+ String prefix = "uddi";
+ String uddins = IRegistry.UDDI_V2_NAMESPACE;
+ int len = nlist != null ? nlist.getLength() : 0;
+
+ for (int i = 0; i < len; i++)
+ {
+ Node node = nlist.item(i);
+ short nodeType = node != null ? node.getNodeType() : -100;
+ if (Node.ELEMENT_NODE == nodeType)
+ {
+ Element el = (Element)node;
+ Name name = factory.createName(el.getNodeName(), prefix, uddins);
+ SOAPElement attachedEl = bodyElement.addChildElement(name);
+ appendAttributes(attachedEl, el.getAttributes(), factory);
+ appendElements(attachedEl, el.getChildNodes(), factory);
+ }
+ else if (nodeType == Node.TEXT_NODE)
+ {
+ bodyElement.addTextNode(node.getNodeValue());
+ }
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list