Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 64218 Details for
Bug 176493
WSE: Make message/transport stack pluggable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for pluggable transport
patch.txt (text/plain), 184.03 KB, created by
Andrew Mak
on 2007-04-18 15:02:44 EDT
(
hide
)
Description:
Patch for pluggable transport
Filename:
MIME Type:
Creator:
Andrew Mak
Created:
2007-04-18 15:02:44 EDT
Size:
184.03 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.ws.explorer >Index: wsexplorer/wsdl/soap_envelope_xml.jsp >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer/wsdl/soap_envelope_xml.jsp,v >retrieving revision 1.2 >diff -u -r1.2 soap_envelope_xml.jsp >--- wsexplorer/wsdl/soap_envelope_xml.jsp 9 May 2006 12:57:16 -0000 1.2 >+++ wsexplorer/wsdl/soap_envelope_xml.jsp 18 Apr 2007 18:13:09 -0000 >@@ -1,28 +1,34 @@ > <% > /******************************************************************************* >- * Copyright (c) 2001, 2004 IBM Corporation and others. >+ * Copyright (c) 2001, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * IBM Corporation - initial API and implementation >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > %><%@ page contentType="text/xml; charset=UTF-8" import="org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*, >- org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*" %><jsp:useBean id="controller" class="org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller" scope="session"/><% >+ org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*, >+ org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement, >+ org.eclipse.wst.ws.internal.explorer.transport.*" %><jsp:useBean id="controller" class="org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller" scope="session"/><% > int soapEnvelopeType = Integer.parseInt(request.getParameter(WSDLActionInputs.SOAP_ENVELOPE_TYPE)); > WSDLPerspective wsdlPerspective = controller.getWSDLPerspective(); >-SOAPMessageQueue soapMessageQueue; >+WSDLOperationElement operElement = (WSDLOperationElement) wsdlPerspective.getOperationNode().getTreeElement(); >+ISOAPMessage soapMessage; > switch (soapEnvelopeType) > { > case WSDLActionInputs.SOAP_ENVELOPE_TYPE_REQUEST: >- soapMessageQueue = wsdlPerspective.getSOAPRequestQueue(); >+ soapMessage = (ISOAPMessage) operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOAP_REQUEST); > break; > case WSDLActionInputs.SOAP_ENVELOPE_TYPE_RESPONSE: > default: >- soapMessageQueue = wsdlPerspective.getSOAPResponseQueue(); >+ soapMessage = (ISOAPMessage) operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOAP_RESPONSE); > break; > } >-String messages = soapMessageQueue.getMessagesFromList(); >+String messages = soapMessage.toXML(); > %><%=messages%> >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/plugin.xml,v >retrieving revision 1.3 >diff -u -r1.3 plugin.xml >--- plugin.xml 14 Jun 2005 19:34:49 -0000 1.3 >+++ plugin.xml 18 Apr 2007 18:13:09 -0000 >@@ -2,6 +2,7 @@ > <?eclipse version="3.0"?> > > <plugin> >+ <extension-point id="wseTransportProvider" name="%XP_WSE_TRANSPORT_PROVIDER" schema="schema/wseTransportProvider.exsd"/> > > > <!-- ================================================================= --> >@@ -43,5 +44,13 @@ > </action> > </objectContribution> > </extension> >- >+ <extension >+ point="org.eclipse.wst.ws.explorer.wseTransportProvider"> >+ <soapTransportProvider >+ class="org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.SOAPTransportProvider" >+ id="org.eclipse.wst.ws.explorer.soapTransportProvider" >+ name="%SOAP_TRANSPORT_PROVIDER" >+ namespaceURI="http://schemas.xmlsoap.org/wsdl/soap/" >+ transportURI="http://schemas.xmlsoap.org/soap/http"/> >+ </extension> > </plugin> >Index: build.properties >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/build.properties,v >retrieving revision 1.15 >diff -u -r1.15 build.properties >--- build.properties 7 Sep 2006 01:12:21 -0000 1.15 >+++ build.properties 18 Apr 2007 18:13:09 -0000 >@@ -12,7 +12,9 @@ > wsexplorer.war,\ > META-INF/,\ > about.html,\ >- wsexplorer-properties.jar >+ wsexplorer-properties.jar,\ >+ wsexplorer/WEB-INF/lib/wsexplorer.jar,\ >+ schema/ > > > custom = false >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/plugin.properties,v >retrieving revision 1.1 >diff -u -r1.1 plugin.properties >--- plugin.properties 19 Apr 2005 17:35:01 -0000 1.1 >+++ plugin.properties 18 Apr 2007 18:13:09 -0000 >@@ -1,12 +1,15 @@ > ############################################################################### >-# Copyright (c) 2001, 2004 IBM Corporation and others. >+# Copyright (c) 2001, 2007 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at > # http://www.eclipse.org/legal/epl-v10.html > # > # Contributors: >-# IBM Corporation - initial API and implementation >+# IBM Corporation - initial API and implementation >+# yyyymmdd bug Email and other contact information >+# -------- -------- ----------------------------------------------------------- >+# 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > ############################################################################### > > # >@@ -15,6 +18,9 @@ > PLUGIN_NAME=Web Services Explorer > PLUGIN_PROVIDER=Eclipse.org > >+XP_WSE_TRANSPORT_PROVIDER=Web Services Explorer Transport Provider >+SOAP_TRANSPORT_PROVIDER=Default SOAP Transport Provider >+ > # > # Messages for the client type extension > # >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationSourceAction.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationSourceAction.java,v >retrieving revision 1.4 >diff -u -r1.4 InvokeWSDLSOAPOperationSourceAction.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationSourceAction.java 28 Mar 2007 13:51:41 -0000 1.4 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationSourceAction.java 18 Apr 2007 18:13:09 -0000 >@@ -10,36 +10,28 @@ > * yyyymmdd bug Email and other contact information > * -------- -------- ----------------------------------------------------------- > * 20070305 117034 makandre@ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; > > import java.io.OutputStream; > import java.io.PrintWriter; > import java.util.Hashtable; >-import java.util.Vector; >-import javax.xml.parsers.ParserConfigurationException; >+ > import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; > import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; > import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; >-import org.eclipse.wst.ws.internal.explorer.platform.util.XMLUtils; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLActionInputs; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLModelConstants; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLBindingElement; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLElement; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLServiceElement; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.SoapHelper; >-import org.w3c.dom.Element; >-import org.w3c.dom.NodeList; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage; > > public class InvokeWSDLSOAPOperationSourceAction extends InvokeWSDLSOAPOperationAction > { > private boolean newFileSelected_; > private boolean saveAsSelected_; > private boolean isHeader_; >- private static final String DUMMY_WRAPPER_START_TAG = "<dummyWrapper>"; >- private static final String DUMMY_WRAPPER_END_TAG = "</dummyWrapper>"; > > public InvokeWSDLSOAPOperationSourceAction(Controller controller) > { >@@ -120,66 +112,30 @@ > return false; > */ > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.InvokeWSDLSOAPOperationAction#getSOAPRequestMessage(org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement) >+ */ >+ protected ISOAPMessage getSOAPRequestMessage(WSDLOperationElement operElement) { >+ return (ISOAPMessage) operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOAP_REQUEST_TMP); >+ } > >- protected Vector getHeaderEntries(Hashtable soapEnvelopeNamespaceTable, WSDLOperationElement operElement) throws ParserConfigurationException, Exception { >- >- Vector headerEntries = new Vector(); >- String[] nsDeclarations = (String[])operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE); >- for (int i = 0; i < nsDeclarations.length; i++) >- { >- String[] prefix_ns = SoapHelper.decodeNamespaceDeclaration(nsDeclarations[i]); >- if (!soapEnvelopeNamespaceTable.contains(prefix_ns[1])) >- soapEnvelopeNamespaceTable.put(prefix_ns[1], prefix_ns[0]); >- } >- StringBuffer sourceContent = new StringBuffer(operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT_HEADER)); >- sourceContent.insert(0,DUMMY_WRAPPER_START_TAG).append(DUMMY_WRAPPER_END_TAG); >- Element dummyWrapperElement = XMLUtils.stringToElement(sourceContent.toString()); >- NodeList nl = dummyWrapperElement.getChildNodes(); >- for (int i = 0; i < nl.getLength(); i++) >- { >- if (nl.item(i) instanceof Element) >- headerEntries.add(nl.item(i)); >- } >- >- return headerEntries; >- } >- >- /** >- * Generate a Vector of the elements inside the Soap Body. >- * @param soapEnvelopeNamespaceTable - Hashtable containing a map of the namespace URIs to prefixes. >- * @param operElement - WSDLOperationElement encapsulating the WSDL operation. >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.InvokeWSDLSOAPOperationAction#setHeaderContent(java.util.Hashtable, org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement, org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage) > */ >- protected Vector getBodyEntries(Hashtable soapEnvelopeNamespaceTable,WSDLOperationElement operElement,WSDLBindingElement bindingElement,WSDLServiceElement serviceElement) throws ParserConfigurationException,Exception >- { >- Vector bodyEntries = new Vector(); >- String[] nsDeclarations = (String[])operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE); >- for (int i = 0; i < nsDeclarations.length; i++) >- { >- String[] prefix_ns = SoapHelper.decodeNamespaceDeclaration(nsDeclarations[i]); >- if (!soapEnvelopeNamespaceTable.contains(prefix_ns[1])) >- soapEnvelopeNamespaceTable.put(prefix_ns[1], prefix_ns[0]); >- } >- StringBuffer sourceContent = new StringBuffer(operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT)); >- sourceContent.insert(0,DUMMY_WRAPPER_START_TAG).append(DUMMY_WRAPPER_END_TAG); >- Element dummyWrapperElement = XMLUtils.stringToElement(sourceContent.toString()); >- NodeList nl = dummyWrapperElement.getChildNodes(); >- for (int i = 0; i < nl.getLength(); i++) >- { >- if (nl.item(i) instanceof Element) >- bodyEntries.add(nl.item(i)); >- } >- if (!operElement.isDocumentStyle()) >- { >- try >- { >- addRPCWrapper(bodyEntries,(WSDLElement)serviceElement.getParentElement(),operElement,soapEnvelopeNamespaceTable); >- } >- catch (ParserConfigurationException e) >- { >- throw e; >- } >- } >- return bodyEntries; >+ protected void setHeaderContent(Hashtable soapEnvelopeNamespaceTable, WSDLOperationElement operElement, ISOAPMessage soapMessage) { >+ String headerContent = operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT_HEADER); >+ operElement.getSOAPTransportProvider().newTransport().newDeserializer() >+ .deserialize(ISOAPMessage.HEADER_CONTENT, headerContent, soapMessage); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.InvokeWSDLSOAPOperationAction#setBodyContent(java.util.Hashtable, org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement, org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage) >+ */ >+ protected void setBodyContent(Hashtable soapEnvelopeNamespaceTable, WSDLOperationElement operElement, ISOAPMessage soapMessage) { >+ String bodyContent = operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT); >+ operElement.getSOAPTransportProvider().newTransport().newDeserializer() >+ .deserialize(ISOAPMessage.BODY_CONTENT, bodyContent, soapMessage); > } > > public final boolean wasNewFileSelected() >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationAction.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationAction.java,v >retrieving revision 1.4 >diff -u -r1.4 InvokeWSDLSOAPOperationAction.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationAction.java 28 Mar 2007 13:51:41 -0000 1.4 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationAction.java 18 Apr 2007 18:13:09 -0000 >@@ -10,48 +10,32 @@ > * yyyymmdd bug Email and other contact information > * -------- -------- ----------------------------------------------------------- > * 20070305 117034 makandre@ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; > >-import java.io.BufferedReader; > import java.io.IOException; > import java.util.Hashtable; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Vector; >+ > import javax.servlet.http.HttpServletResponse; >-import javax.wsdl.BindingInput; >-import javax.wsdl.BindingOperation; >-import javax.wsdl.Definition; >-import javax.wsdl.Part; >-import javax.wsdl.extensions.ExtensibilityElement; >-import javax.wsdl.extensions.soap.SOAPBody; >-import javax.xml.parsers.DocumentBuilder; >-import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.ParserConfigurationException; >-import org.apache.axis.Constants; >+ > import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; > import org.eclipse.wst.ws.internal.explorer.platform.perspective.MessageQueue; > import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; > import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; >-import org.eclipse.wst.ws.internal.explorer.platform.util.XMLUtils; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLActionInputs; >+import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLModelConstants; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.Endpoint; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLBindingElement; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLElement; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLServiceElement; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.InvokeWSDLOperationTool; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.SOAPMessageQueue; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.HTTPException; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.HTTPTransport; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.SoapHelper; >-import org.eclipse.wst.ws.internal.parser.discovery.NetUtils; >-import org.eclipse.wst.wsdl.binding.soap.SOAPHeader; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >+import org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.SOAPMessageUtils; >+import org.eclipse.wst.ws.internal.explorer.transport.HTTPTransportException; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransportProvider; >+import org.eclipse.wst.ws.internal.explorer.transport.TransportException; > > public abstract class InvokeWSDLSOAPOperationAction extends WSDLPropertiesFormAction > { >@@ -69,182 +53,43 @@ > return true; > } > >- protected final void addRPCWrapper(Vector bodyEntries,WSDLElement wsdlElement,WSDLOperationElement operElement,Hashtable soapEnvelopeNamespaceTable) throws ParserConfigurationException >- { >- // Must be RPC style. >- String encodingNamespaceURI = null; >- /* >- * WS-I: In a rpc-literal SOAP binding, the serialized child element of the >- * soap:Body element consists of a wrapper element, whose namespace is the value >- * of the namespace attribute of the soapbind:body element and whose local name is >- * either the name of the operation or the name of the operation suffixed >- * with "Response". The namespace attribute is required, as opposed to being >- * optional, to ensure that the children of the soap:Body element are namespace- >- * qualified. >- */ >- BindingOperation bindingOperation = operElement.getBindingOperation(); >- if (bindingOperation != null) >- { >- BindingInput bindingInput = bindingOperation.getBindingInput(); >- if (bindingInput != null) >- { >- List extElements = bindingInput.getExtensibilityElements(); >- for (Iterator it = extElements.iterator(); it.hasNext();) >- { >- ExtensibilityElement extElement = (ExtensibilityElement)it.next(); >- if (extElement instanceof SOAPBody) >- { >- encodingNamespaceURI = ((SOAPBody)extElement).getNamespaceURI(); >- break; >- } >- } >- } >- } >- // If the namespace of the soapbind:body element is not set, get it from the operation element >- if (encodingNamespaceURI == null) >- encodingNamespaceURI = operElement.getEncodingNamespace(); >- // If the namespace of the operation element is not set, get it from the definition element >- if (encodingNamespaceURI == null) >- { >- Definition definition = wsdlElement.getDefinition(); >- encodingNamespaceURI = definition.getTargetNamespace(); >- } >- // Generate an RPC style wrapper element. >- Document doc = XMLUtils.createNewDocument(null); >- String encodingStyle = (operElement.isUseLiteral() ? null : operElement.getEncodingStyle()); >- Element wrapperElement = SoapHelper.createRPCWrapperElement(doc,soapEnvelopeNamespaceTable,encodingNamespaceURI,operElement.getOperation().getName(),encodingStyle); >- for (int i=0;i<bodyEntries.size();i++) >- wrapperElement.appendChild(doc.importNode((Element)bodyEntries.elementAt(i),true)); >- bodyEntries.removeAllElements(); >- bodyEntries.addElement(wrapperElement); >- } >- > /** >- * Generate a Vector of the elements inside the Soap Header. >- * @param soapEnvelopeNamespaceTable - Hashtable containing a map of the namespace URIs to prefixes. >- * @param operElement - WSDLOperationElement encapsulating the WSDL operation. >+ * Returns an ISOAPMessage to use for the current SOAP operation invocation. >+ * >+ * @param operElement The operation element from the WSDL model. >+ * >+ * @return An ISOAPMessage, or null if a message cannot be constructed. > */ >- protected Vector getHeaderEntries(Hashtable soapEnvelopeNamespaceTable,WSDLOperationElement operElement) throws ParserConfigurationException,Exception >- { >- Vector headerEntries = new Vector(); >- >- Iterator it = operElement.getSOAPHeaders().iterator(); >- while (it.hasNext()) >- { >- SOAPHeader soapHeader = (SOAPHeader) it.next(); >- >- StringBuffer encodingStyle = null; >- boolean isUseLiteral = "literal".equals(soapHeader.getUse()); >- >- if (!isUseLiteral) { >- Iterator encodingStyles = soapHeader.getEncodingStyles().iterator(); >- encodingStyle = new StringBuffer(); >- while (encodingStyles.hasNext()) { >- Object next = encodingStyles.next(); >- if (Constants.URI_SOAP11_ENC.equals(next)) >- continue; >- encodingStyle.append(" ").append(next); >- } >- } >- >- IXSDFragment frag = (IXSDFragment)operElement.getHeaderFragment(soapHeader); >- Element[] instanceDocuments = frag.genInstanceDocumentsFromParameterValues(!isUseLiteral,soapEnvelopeNamespaceTable, XMLUtils.createNewDocument(null)); >- for (int j=0;j<instanceDocuments.length;j++) >- { >- if (instanceDocuments[j] == null) >- continue; >- if (encodingStyle != null && encodingStyle.length() > 0) >- instanceDocuments[j].setAttribute("soapenv:encodingStyle",encodingStyle.substring(1)); >- headerEntries.addElement(instanceDocuments[j]); >- } >- } >- >- return headerEntries; >+ protected ISOAPMessage getSOAPRequestMessage(WSDLOperationElement operElement) { >+ ISOAPTransportProvider provider = operElement.getSOAPTransportProvider(); >+ if (provider == null) >+ return null; >+ return provider.newTransport().newMessage(operElement.getMessageContext()); > } > > /** >- * Generate a Vector of the elements inside the Soap Body. >- * @param soapEnvelopeNamespaceTable - Hashtable containing a map of the namespace URIs to prefixes. >- * @param operElement - WSDLOperationElement encapsulating the WSDL operation. >+ * Populate the given ISOAPMessage's header using the inputs from WSE >+ * >+ * @param soapEnvelopeNamespaceTable Hashtable containing a map of the namespace URIs to prefixes. >+ * @param operElement WSDLOperationElement encapsulating the WSDL operation. >+ * @param soapMessage The ISOAPMessage to populate > */ >- protected Vector getBodyEntries(Hashtable soapEnvelopeNamespaceTable,WSDLOperationElement operElement,WSDLBindingElement bindingElement,WSDLServiceElement serviceElement) throws ParserConfigurationException,Exception >- { >- Vector bodyEntries = new Vector(); >- boolean isUseLiteral = operElement.isUseLiteral(); >- String encodingStyle = operElement.getEncodingStyle(); >- boolean addEncodingStyle = (!isUseLiteral && !Constants.URI_SOAP11_ENC.equals(encodingStyle)); >- Iterator it = operElement.getOrderedBodyParts().iterator(); >- while (it.hasNext()) >- { >- Part part = (Part)it.next(); >- IXSDFragment frag = (IXSDFragment)operElement.getFragment(part); >- Element[] instanceDocuments = frag.genInstanceDocumentsFromParameterValues(!isUseLiteral,soapEnvelopeNamespaceTable, XMLUtils.createNewDocument(null)); >- for (int j=0;j<instanceDocuments.length;j++) >- { >- if (instanceDocuments[j] == null) >- continue; >- if (addEncodingStyle) >- instanceDocuments[j].setAttribute("soapenv:encodingStyle",encodingStyle); >- bodyEntries.addElement(instanceDocuments[j]); >- } >- } >- >- if (!operElement.isDocumentStyle()) >- { >- try >- { >- addRPCWrapper(bodyEntries,(WSDLElement)serviceElement.getParentElement(),operElement,soapEnvelopeNamespaceTable); >- } >- catch (ParserConfigurationException e) >- { >- throw e; >- } >- } >- return bodyEntries; >- } >- >- protected Element getSOAPEnvelope(Hashtable soapEnvelopeNamespaceTable, Vector bodyEntries) throws ParserConfigurationException >- { >- return getSOAPEnvelope(soapEnvelopeNamespaceTable, null, bodyEntries); >- } >- >- protected Element getSOAPEnvelope(Hashtable soapEnvelopeNamespaceTable, Vector headerEntries, Vector bodyEntries) throws ParserConfigurationException >- { >- DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); >- Document doc = XMLUtils.createNewDocument(docBuilder); >- Element soapEnvelopeElement = SoapHelper.createSoapEnvelopeElement(doc,soapEnvelopeNamespaceTable); >- >- if (headerEntries != null && !headerEntries.isEmpty()) { >- Element soapHeaderElement = SoapHelper.createSoapHeaderElement(doc); >- for (int i=0;i<headerEntries.size();i++) >- soapHeaderElement.appendChild(doc.importNode((Element)headerEntries.elementAt(i),true)); >- soapEnvelopeElement.appendChild(soapHeaderElement); >- } >- >- Element soapBodyElement = SoapHelper.createSoapBodyElement(doc); >- for (int i=0;i<bodyEntries.size();i++) >- soapBodyElement.appendChild(doc.importNode((Element)bodyEntries.elementAt(i),true)); >- soapEnvelopeElement.appendChild(soapBodyElement); >- return soapEnvelopeElement; >- } >- >- private final void recordSoapRequest(SOAPMessageQueue soapRequestQueue,Hashtable soapEnvelopeNamespaceTable,Element soapEnvelope) throws ParserConfigurationException,IOException >- { >- soapRequestQueue.clear(); >- soapRequestQueue.addMessage(XMLUtils.serialize(soapEnvelope,false)); >+ protected void setHeaderContent(Hashtable soapEnvelopeNamespaceTable, WSDLOperationElement operElement, ISOAPMessage soapMessage) >+ throws ParserConfigurationException { >+ SOAPMessageUtils.setHeaderContentFromModel(soapEnvelopeNamespaceTable, operElement, soapMessage); > } > >- private final void recordSOAPResponse(SOAPMessageQueue soapResponseQueue,BufferedReader responseReader) throws IOException >- { >- soapResponseQueue.clear(); >- if (responseReader != null) >- { >- String line = null; >- while ((line = responseReader.readLine()) != null) >- soapResponseQueue.addMessage(line); >- responseReader.close(); >- } >- } >+ /** >+ * Populate the given ISOAPMessage's body using the inputs from WSE >+ * >+ * @param soapEnvelopeNamespaceTable Hashtable containing a map of the namespace URIs to prefixes. >+ * @param operElement WSDLOperationElement encapsulating the WSDL operation. >+ * @param soapMessage The ISOAPMessage to populate >+ */ >+ protected void setBodyContent(Hashtable soapEnvelopeNamespaceTable, WSDLOperationElement operElement, ISOAPMessage soapMessage) >+ throws ParserConfigurationException { >+ SOAPMessageUtils.setBodyContentFromModel(soapEnvelopeNamespaceTable, operElement, soapMessage); >+ } > > public boolean run() > { >@@ -253,7 +98,6 @@ > MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); > WSDLOperationElement operElement = (WSDLOperationElement)getSelectedNavigatorNode().getTreeElement(); > WSDLBindingElement bindingElement = (WSDLBindingElement)operElement.getParentElement(); >- WSDLServiceElement serviceElement = (WSDLServiceElement)bindingElement.getParentElement(); > operElement.setPropertyAsObject(WSDLActionInputs.SOAP_RESPONSE_CACHED, new Boolean(false)); > try > { >@@ -263,47 +107,52 @@ > // xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > // xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > // ... >- Hashtable soapEnvelopeNamespaceTable = new Hashtable(); >- SoapHelper.addDefaultSoapEnvelopeNamespaces(soapEnvelopeNamespaceTable); >- Vector headerEntries = getHeaderEntries(soapEnvelopeNamespaceTable, operElement); >- Vector bodyEntries = getBodyEntries(soapEnvelopeNamespaceTable,operElement,bindingElement,serviceElement); >- Element soapEnvelope = getSOAPEnvelope(soapEnvelopeNamespaceTable, headerEntries, bodyEntries); >- recordSoapRequest(wsdlPerspective.getSOAPRequestQueue(),soapEnvelopeNamespaceTable,soapEnvelope); > >- // Execute the SOAP operation. >+ ISOAPMessage soapMessage = getSOAPRequestMessage(operElement); >+ if (soapMessage == null) >+ throw new TransportException(wsdlPerspective.getMessage("MSG_ERROR_NO_SUITABLE_TRANSPORT")); >+ >+ Hashtable namespaceTable = new Hashtable(soapMessage.getNamespaceTable()); >+ setHeaderContent(namespaceTable, operElement, soapMessage); >+ setBodyContent(namespaceTable, operElement, soapMessage); >+ soapMessage.setNamespaceTable(namespaceTable); >+ >+ // store the request >+ operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOAP_REQUEST, soapMessage); >+ >+ // Execute the SOAP operation. > if (soapAddressLocation != null) >- { >- // Send the message and record the SOAP Response Envelope. >- HTTPTransport transport = createTransport(bindingElement, soapAddressLocation); >- transport.send(NetUtils.createURL(soapAddressLocation),operElement.getSoapAction(),XMLUtils.serialize(soapEnvelope, true)); >- recordSOAPResponse(wsdlPerspective.getSOAPResponseQueue(),transport.receive()); >+ { >+ soapMessage.setProperty(ISOAPMessage.PROP_SOAP_ACTION, operElement.getSoapAction()); >+ String[] authParams = retrieveAuthParams(bindingElement, soapAddressLocation); >+ >+ // invoke! >+ ISOAPMessage soapResponse = operElement.getSOAPTransportProvider().newTransport() >+ .send(soapAddressLocation, authParams[0], authParams[1], soapMessage); >+ >+ // store the response >+ operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOAP_RESPONSE, soapResponse); >+ > wsdlPerspective.setOperationNode(getSelectedNavigatorNode()); > return true; > } > throw new IOException(wsdlPerspective.getMessage("MSG_ERROR_UNABLE_TO_CONNECT",soapAddressLocation)); > } >- catch (ParserConfigurationException e) >- { >- handleUnexpectedException(wsdlPerspective,messageQueue,"ParserConfigurationException",e); >- } >- catch (IOException e) >- { >- handleUnexpectedException(wsdlPerspective,messageQueue,"IOException",e); >+ catch (HTTPTransportException e) { >+ throwHTTPTransportException(bindingElement, soapAddressLocation, e); > } >- catch (HTTPException httpe) >- { >- throwHTTPException(bindingElement, soapAddressLocation, httpe); >- } >- catch (Exception e) >- { >- handleUnexpectedException(wsdlPerspective,messageQueue,"Exception",e); >+ catch (Exception e) { >+ Throwable t = e; >+ if (e instanceof TransportException && e.getCause() != null) >+ t = e.getCause(); >+ handleUnexpectedException(wsdlPerspective, messageQueue, t.getClass().getSimpleName(), t); > } > return false; > } > >- private void throwHTTPException(WSDLBindingElement bindingElement, String endpointString, HTTPException httpException) throws HTTPException >+ private void throwHTTPTransportException(WSDLBindingElement bindingElement, String endpointString, HTTPTransportException httpTransportException) throws HTTPTransportException > { >- if (httpException.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) >+ if (httpTransportException.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) > { > Endpoint endpoint = bindingElement.getEndpoint(endpointString); > if (endpoint != null) >@@ -313,12 +162,12 @@ > endpoint.setHttpBasicAuthPassword(null); > } > } >- throw httpException; >+ throw httpTransportException; > } > >- private HTTPTransport createTransport(WSDLBindingElement bindingElement, String endpointString) >+ private String[] retrieveAuthParams(WSDLBindingElement bindingElement, String endpointString) > { >- HTTPTransport transport = new HTTPTransport(); >+ String[] authParams = new String[] { null, null }; > Endpoint endpoint = bindingElement.getEndpoint(endpointString); > if (endpoint != null) > { >@@ -335,11 +184,11 @@ > } > if (httpBasicAuthUsername != null && httpBasicAuthPassword != null) > { >- transport.setHttpBasicAuthUsername(httpBasicAuthUsername); >- transport.setHttpBasicAuthPassword(httpBasicAuthPassword); >+ authParams[0] = httpBasicAuthUsername; >+ authParams[1] = httpBasicAuthPassword; > } > } > } >- return transport; >+ return authParams; > } > } >\ No newline at end of file >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SynchronizeFragmentViewsAction.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SynchronizeFragmentViewsAction.java,v >retrieving revision 1.3 >diff -u -r1.3 SynchronizeFragmentViewsAction.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SynchronizeFragmentViewsAction.java 28 Mar 2007 13:51:41 -0000 1.3 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SynchronizeFragmentViewsAction.java 18 Apr 2007 18:13:09 -0000 >@@ -10,28 +10,29 @@ > * yyyymmdd bug Email and other contact information > * -------- -------- ----------------------------------------------------------- > * 20070305 117034 makandre@ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; > >-import java.util.Hashtable; > import java.util.Iterator; >-import java.util.Vector; >+import java.util.Map; >+ > import javax.wsdl.Part; >+ > import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; > import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; > import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; > import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; >-import org.eclipse.wst.ws.internal.explorer.platform.util.XMLUtils; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLModelConstants; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.SOAPHeaderWrapperFragment; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.InvokeWSDLOperationTool; >-import org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.SoapHelper; >+import org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.SOAPMessageUtils; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage; > import org.eclipse.wst.wsdl.binding.soap.SOAPHeader; > import org.w3c.dom.Element; >-import org.w3c.dom.NodeList; > > public class SynchronizeFragmentViewsAction extends WSDLPropertiesFormAction > { >@@ -52,14 +53,24 @@ > if (viewID.equals(FragmentConstants.FRAGMENT_VIEW_SWITCH_FORM_TO_SOURCE)) > { > invokeWSDLOperationTool.setFragmentViewID(FragmentConstants.FRAGMENT_VIEW_SWITCH_FORM_TO_SOURCE); >+ operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE, null); >+ > return processFormViewParsedResultsHeader(parser, operElement) & // need to process both header and body > processFormViewParsedResults(parser, operElement); > } > else > { > invokeWSDLOperationTool.setFragmentViewID(FragmentConstants.FRAGMENT_VIEW_SWITCH_SOURCE_TO_FORM); >- return processSourceViewParsedResultsHeader(parser, operElement) & // need to process both header and body >- processSourceViewParsedResults(parser, operElement); >+ String[] nsDeclarations = parser.getParameterValues(FragmentConstants.SOURCE_CONTENT_NAMESPACE); >+ if (nsDeclarations != null) >+ operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE,nsDeclarations); >+ >+ ISOAPMessage soapMessage = (ISOAPMessage) operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOAP_REQUEST_TMP); >+ boolean rc = processSourceViewParsedResultsHeader(parser, operElement, soapMessage) & // need to process both header and body >+ processSourceViewParsedResults(parser, operElement, soapMessage); >+ operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOAP_REQUEST_TMP, null); >+ >+ return rc; > } > } > >@@ -84,7 +95,6 @@ > private boolean processFormViewParsedResults(MultipartFormDataParser parser, WSDLOperationElement operElement) throws MultipartFormDataException > { > operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT, null); >- operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE, null); > boolean resultsValid = true; > > Iterator it = operElement.getOrderedBodyParts().iterator(); >@@ -99,53 +109,47 @@ > operElement.setPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT,null); > return resultsValid; > } >- >- private boolean processSourceViewParsedResultsHeader(MultipartFormDataParser parser, WSDLOperationElement operElement) throws MultipartFormDataException >- { >+ >+ private boolean processSourceViewParsedResultsHeader(MultipartFormDataParser parser, WSDLOperationElement operElement, ISOAPMessage soapMessage) >+ throws MultipartFormDataException { >+ > String sourceContent = parser.getParameter(FragmentConstants.SOURCE_CONTENT_HEADER); > if (sourceContent != null) > operElement.setPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT_HEADER, sourceContent); >- String[] nsDeclarations = parser.getParameterValues(FragmentConstants.SOURCE_CONTENT_NAMESPACE); >- if (nsDeclarations != null) >- operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE,nsDeclarations); >- >+ > Iterator it = operElement.getSOAPHeaders().iterator(); > if (!it.hasNext()) > return true; >- >- Hashtable namespaceTable = new Hashtable(); > >- if (nsDeclarations != null) { >- for (int i = 0; i < nsDeclarations.length; i++) >- { >- String[] prefix_ns = SoapHelper.decodeNamespaceDeclaration(nsDeclarations[i]); >- if (!namespaceTable.contains(prefix_ns[1])) >- namespaceTable.put(prefix_ns[1], prefix_ns[0]); >- } >- } >- >- sourceContent = addRootElement(sourceContent); > try > { >- Element sourceElements = XMLUtils.stringToElement(sourceContent); >- NodeList nl = sourceElements.getChildNodes(); >- >- Hashtable elements = new Hashtable(); >- >- // work backwards so that if there are multiple nodes with the same name >- // the topmost one takes precedence >- for (int i = nl.getLength() - 1; i >= 0; i--) { >- org.w3c.dom.Node node = nl.item(i); >- if (node != null && node instanceof Element) >- elements.put(node.getNodeName(), node); >- } >+ operElement.getSOAPTransportProvider().newTransport().newDeserializer() >+ .deserialize(ISOAPMessage.HEADER_CONTENT, sourceContent, soapMessage); >+ >+ Element[] instanceDocuments = soapMessage.getHeaderContent(); >+ Map namespaceTable = soapMessage.getNamespaceTable(); > > boolean sourceElementsValid = true; >- while (it.hasNext()) >+ int start = 0; >+ while (it.hasNext() && start < instanceDocuments.length) > { > SOAPHeader soapHeader = (SOAPHeader)it.next(); > SOAPHeaderWrapperFragment frag = (SOAPHeaderWrapperFragment) operElement.getHeaderFragment(soapHeader); >- if (!frag.setParameterValuesFromInstanceDocuments(elements, namespaceTable)) >+ >+ int pos = SOAPMessageUtils.findFirstMatchingElement( >+ soapHeader.getEPart(), >+ instanceDocuments, >+ namespaceTable, >+ frag.getName(), >+ start); >+ >+ if (pos == -1) >+ continue; >+ >+ Element element = instanceDocuments[pos]; >+ start = pos + 1; >+ >+ if (!frag.setParameterValuesFromInstanceDocument(element, namespaceTable)) > sourceElementsValid = false; > } > return sourceElementsValid; >@@ -156,28 +160,22 @@ > } > } > >- private boolean processSourceViewParsedResults(MultipartFormDataParser parser, WSDLOperationElement operElement) throws MultipartFormDataException >- { >+ private boolean processSourceViewParsedResults(MultipartFormDataParser parser, WSDLOperationElement operElement, ISOAPMessage soapMessage) >+ throws MultipartFormDataException { >+ > String sourceContent = parser.getParameter(FragmentConstants.SOURCE_CONTENT); > if (sourceContent != null) > operElement.setPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT, sourceContent); > > Iterator it = operElement.getOrderedBodyParts().iterator(); > >- sourceContent = addRootElement(sourceContent); > try > { >- Element sourceElements = XMLUtils.stringToElement(sourceContent); >- NodeList nl = sourceElements.getChildNodes(); >- Vector elementsVector = new Vector(); >- for (int i = 0; i < nl.getLength(); i++) >- { >- org.w3c.dom.Node node = nl.item(i); >- if (node != null && node instanceof Element) >- elementsVector.add(node); >- } >- Element[] instanceDocuments = new Element[elementsVector.size()]; >- elementsVector.copyInto(instanceDocuments); >+ operElement.getSOAPTransportProvider().newTransport().newDeserializer() >+ .deserialize(ISOAPMessage.BODY_CONTENT, sourceContent, soapMessage); >+ >+ Element[] instanceDocuments = soapMessage.getBodyContent(); >+ > boolean sourceElementsValid = true; > while (it.hasNext()) > { >@@ -194,15 +192,6 @@ > } > } > >- private String addRootElement(String element) >- { >- StringBuffer sb = new StringBuffer(); >- sb.append(FragmentConstants.ROOT_ELEMENT_START_TAG); >- sb.append(element); >- sb.append(FragmentConstants.ROOT_ELEMENT_END_TAG); >- return sb.toString(); >- } >- > public boolean run() { > return true; > } >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPTransport.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPTransport.java,v >retrieving revision 1.11 >diff -u -r1.11 HTTPTransport.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPTransport.java 23 Aug 2006 18:24:56 -0000 1.11 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPTransport.java 18 Apr 2007 18:13:09 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * Copyright (c) 2004, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -13,6 +13,7 @@ > * 20060222 118019 andyzhai@ca.ibm.com - Andy Zhai > * 20060222 128564 jesper@selskabet.org - Jesper S Moller > * 20060823 99034 makandre@ca.ibm.com - Andrew Mak, WSE support for basic-authenticating firewalls >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; > >@@ -30,6 +31,7 @@ > import java.util.Hashtable; > import javax.net.ssl.SSLSocketFactory; > import org.eclipse.wst.ws.internal.explorer.platform.util.XMLUtils; >+import org.eclipse.wst.ws.internal.explorer.transport.HTTPTransportException; > import org.w3c.dom.Element; > import sun.misc.BASE64Encoder; > >@@ -335,7 +337,7 @@ > code = httpResponse.getStatusCode(); > String contentType = httpResponse.getHeader(HTTP_HEADER_CONTENT_TYPE.toLowerCase()); > if (code >= HTTP_CODE_EXCEPTION && (contentType == null || contentType.toLowerCase().indexOf(TEXT_XML.toLowerCase()) == -1)) >- throw new HTTPException(code, httpResponse.getStatusMessage(), httpResponse.getHeaders()); >+ throw new HTTPTransportException(code, httpResponse.getStatusMessage(), httpResponse.getHeaders()); > } > > private void readHTTPResponseHeader(InputStream is, HTTPResponse resp) throws IOException >@@ -431,14 +433,18 @@ > resp.setPayload(baos.toByteArray()); > } > >- public BufferedReader receive() >+ /** >+ * Receives the bytes from the last web service invocation. This is used by WSE's default >+ * SOAP transport. >+ * >+ * @return A byte array. >+ * @throws IOException >+ */ >+ byte[] receiveBytes() throws IOException > { > if (httpResponse != null) > { >- try >- { > byte[] payload = httpResponse.getPayload(); >- Element soapEnvelope = null; > if (CHUNKED.equalsIgnoreCase(httpResponse.getHeader(HTTP_HEADER_TRANSFER_ENCODEING.toLowerCase()))) > { > ByteArrayInputStream bais = new ByteArrayInputStream(payload); >@@ -450,20 +456,37 @@ > baos.close(); > cis.close(); > bais.close(); >- soapEnvelope = XMLUtils.byteArrayToElement(baos.toByteArray(), false); >+ return baos.toByteArray(); > } > else > { >- soapEnvelope = XMLUtils.byteArrayToElement(payload, false); >+ return payload; > } >+ } >+ return null; >+ } >+ >+ /** >+ * This method is deprecated after WSE swtiches to using a pluggable transport via enhancement 176493. >+ * The core functionality of this method is refactored to the receiveBytes() method. >+ * >+ * @deprecated >+ */ >+ public BufferedReader receive() >+ { >+ try >+ { >+ byte[] payload = receiveBytes(); >+ if (payload != null) { >+ Element soapEnvelope = XMLUtils.byteArrayToElement(payload, false); > // remove XML namespace declaration > if (soapEnvelope != null) >- return new BufferedReader(new InputStreamReader(new ByteArrayInputStream(XMLUtils.serialize(soapEnvelope, true).getBytes(DEFAULT_SOAP_ENCODING)), DEFAULT_SOAP_ENCODING)); >- } >- catch (Throwable t) >- { >+ return new BufferedReader(new InputStreamReader(new ByteArrayInputStream(XMLUtils.serialize(soapEnvelope, true).getBytes(DEFAULT_SOAP_ENCODING)), DEFAULT_SOAP_ENCODING)); > } > } >+ catch (Throwable t) >+ { >+ } > return null; > } > >@@ -525,7 +548,7 @@ > > // ensure we are successfully connected to the proxy > if (code != HTTP_CODE_OK) >- throw new HTTPException(code, httpResponse.getStatusMessage(), httpResponse.getHeaders()); >+ throw new HTTPTransportException(code, httpResponse.getStatusMessage(), httpResponse.getHeaders()); > > return tunnel; > } >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPException.java >=================================================================== >RCS file: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPException.java >diff -N wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPException.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPException.java 19 Apr 2005 17:35:02 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,56 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; >- >-import java.util.Map; >- >-public class HTTPException extends RuntimeException >-{ >- /** >- * Comment for <code>serialVersionUID</code> >- */ >- private static final long serialVersionUID = 3256438105900134961L; >-private int statusCode; >- private String statusMessage; >- private Map headers; >- >- public HTTPException(int statusCode, String statusMessage, Map headers) >- { >- super(statusMessage); >- this.statusCode = statusCode; >- this.statusMessage = statusMessage; >- this.headers = headers; >- } >- >- public int getStatusCode() >- { >- return statusCode; >- } >- >- public String getStatusMessage() >- { >- return statusMessage; >- } >- >- public Map getHeaders() >- { >- return headers; >- } >- >- public String getHeader(String key) >- { >- Object value = headers.get(key); >- if (value != null) >- return value.toString(); >- else >- return null; >- } >-} >\ No newline at end of file >Index: wsexplorer/wsdl/actions/InvokeWSDLSOAPOperationSourceActionJSP.jsp >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer/wsdl/actions/InvokeWSDLSOAPOperationSourceActionJSP.jsp,v >retrieving revision 1.2 >diff -u -r1.2 InvokeWSDLSOAPOperationSourceActionJSP.jsp >--- wsexplorer/wsdl/actions/InvokeWSDLSOAPOperationSourceActionJSP.jsp 12 Aug 2005 18:29:25 -0000 1.2 >+++ wsexplorer/wsdl/actions/InvokeWSDLSOAPOperationSourceActionJSP.jsp 18 Apr 2007 18:13:09 -0000 >@@ -1,23 +1,26 @@ > <% > /******************************************************************************* >- * Copyright (c) 2001, 2004 IBM Corporation and others. >+ * Copyright (c) 2001, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * IBM Corporation - initial API and implementation >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > %> > <%@ page contentType="text/html; charset=UTF-8" import="org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*, > org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.*, > org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.*, > org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLActionInputs, >- org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.HTTPException, > org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.HTTPTransport, > org.eclipse.wst.ws.internal.explorer.platform.perspective.*, > org.eclipse.wst.ws.internal.explorer.platform.constants.*, >+ org.eclipse.wst.ws.internal.explorer.transport.HTTPTransportException, > sun.misc.BASE64Decoder, > javax.servlet.http.HttpServletResponse, > javax.wsdl.*"%> >@@ -128,7 +131,7 @@ > </html> > <% > } >- catch (HTTPException httpe) >+ catch (HTTPTransportException httpe) > { > int code = httpe.getStatusCode(); > if (code == HttpServletResponse.SC_UNAUTHORIZED) >@@ -148,7 +151,7 @@ > MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); > messageQueue.addMessage(controller.getMessage("MSG_ERROR_UNEXPECTED")); > messageQueue.addMessage(String.valueOf(code)); >- messageQueue.addMessage(httpe.getStatusMessage()); >+ messageQueue.addMessage(httpe.getMessage()); > %> > <jsp:include page="/wsdl/scripts/wsdlpanes.jsp" flush="true"/> > <html> >Index: wsexplorer/wsdl/actions/InvokeWSDLSOAPOperationFormActionJSP.jsp >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer/wsdl/actions/InvokeWSDLSOAPOperationFormActionJSP.jsp,v >retrieving revision 1.2 >diff -u -r1.2 InvokeWSDLSOAPOperationFormActionJSP.jsp >--- wsexplorer/wsdl/actions/InvokeWSDLSOAPOperationFormActionJSP.jsp 12 Aug 2005 18:29:25 -0000 1.2 >+++ wsexplorer/wsdl/actions/InvokeWSDLSOAPOperationFormActionJSP.jsp 18 Apr 2007 18:13:09 -0000 >@@ -1,13 +1,16 @@ > <% > /******************************************************************************* >- * Copyright (c) 2001, 2004 IBM Corporation and others. >+ * Copyright (c) 2001, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * IBM Corporation - initial API and implementation >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > %> > <%@ page contentType="text/html; charset=UTF-8" import="org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.*, >@@ -15,8 +18,8 @@ > org.eclipse.wst.ws.internal.explorer.platform.perspective.MessageQueue, > org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLActionInputs, > org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective, >- org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.HTTPException, > org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.HTTPTransport, >+ org.eclipse.wst.ws.internal.explorer.transport.HTTPTransportException, > sun.misc.BASE64Decoder, > javax.servlet.http.HttpServletResponse"%> > >@@ -96,7 +99,7 @@ > </html> > <% > } >- catch (HTTPException httpe) >+ catch (HTTPTransportException httpe) > { > int code = httpe.getStatusCode(); > if (code == HttpServletResponse.SC_UNAUTHORIZED) >@@ -116,7 +119,7 @@ > MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); > messageQueue.addMessage(controller.getMessage("MSG_ERROR_UNEXPECTED")); > messageQueue.addMessage(String.valueOf(code)); >- messageQueue.addMessage(httpe.getStatusMessage()); >+ messageQueue.addMessage(httpe.getMessage()); > %> > <jsp:include page="/wsdl/scripts/wsdlpanes.jsp" flush="true"/> > <html> >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDFragment.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDFragment.java,v >retrieving revision 1.4 >diff -u -r1.4 XSDFragment.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDFragment.java 5 Apr 2006 18:34:10 -0000 1.4 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDFragment.java 18 Apr 2007 18:13:09 -0000 >@@ -1,12 +1,15 @@ > /******************************************************************************* >- * Copyright (c) 2002, 2004 IBM Corporation and others. >+ * Copyright (c) 2002, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * IBM Corporation - initial API and implementation >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; > >@@ -290,11 +293,7 @@ > Node child = children.item(i); > if (child != null) > { >- eCopy.appendChild(child); >- // When you append a node from one element to another, >- // the original element will lose its reference to this node, >- // therefore, the size of the node list will decrease by 1. >- i--; >+ eCopy.appendChild(child.cloneNode(true)); > } > } > for (int j = 0; j < attributes.getLength(); j++) >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPHeaderWrapperFragment.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPHeaderWrapperFragment.java,v >retrieving revision 1.1 >diff -u -r1.1 SOAPHeaderWrapperFragment.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPHeaderWrapperFragment.java 28 Mar 2007 13:51:40 -0000 1.1 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPHeaderWrapperFragment.java 18 Apr 2007 18:13:09 -0000 >@@ -10,6 +10,7 @@ > * yyyymmdd bug Email and other contact information > * -------- -------- ----------------------------------------------------------- > * 20070305 117034 makandre@ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > > package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; >@@ -17,6 +18,7 @@ > import java.net.URI; > import java.net.URISyntaxException; > import java.util.Hashtable; >+import java.util.Map; > import java.util.Vector; > > import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; >@@ -187,23 +189,18 @@ > } > > /** >- * Sets the values for this SOAP header given a hashtable of instance documents and a namespace table. >+ * Sets the values for this SOAP header given an instance document and a namespace table. > * >- * @param instanceDocuments The hashtable of instance documents. The key is the document's name with namespace prefix. >+ * @param instanceDocument The instance document. > * @param namespaceTable The namespace table. > * > * @return True if all values extracted from the instance document are valid. > */ >- public boolean setParameterValuesFromInstanceDocuments(Hashtable instanceDocuments, Hashtable namespaceTable) { >- String tagName = ((XSDFragment) getXSDDelegationFragment()).getInstanceDocumentTagName(namespaceTable); >- Element instanceDocument = (Element) instanceDocuments.get(tagName); >- >- if (instanceDocument == null) >- return false; >- >+ public boolean setParameterValuesFromInstanceDocument(Element instanceDocument, Map namespaceTable) { >+ > boolean valid = setParameterValuesFromInstanceDocuments(new Element[] { instanceDocument }); > >- String prefix = getPrefixFromNamespaceURI(FragmentConstants.NS_URI_SOAP_ENV, namespaceTable) + FragmentConstants.COLON; >+ String prefix = namespaceTable.get(FragmentConstants.NS_URI_SOAP_ENV) + FragmentConstants.COLON; > > String mustUnderstandValue = instanceDocument.getAttribute(prefix + MUST_UNDERSTAND); > if ("".equals(mustUnderstandValue)) >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLOperationElement.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLOperationElement.java,v >retrieving revision 1.4 >diff -u -r1.4 WSDLOperationElement.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLOperationElement.java 28 Mar 2007 13:51:50 -0000 1.4 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLOperationElement.java 18 Apr 2007 18:13:09 -0000 >@@ -10,6 +10,7 @@ > * yyyymmdd bug Email and other contact information > * -------- -------- ----------------------------------------------------------- > * 20070305 117034 makandre@ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > package org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel; > >@@ -21,6 +22,7 @@ > import javax.wsdl.Binding; > import javax.wsdl.BindingInput; > import javax.wsdl.BindingOperation; >+import javax.wsdl.Definition; > import javax.wsdl.Input; > import javax.wsdl.Operation; > import javax.wsdl.Output; >@@ -29,6 +31,7 @@ > import javax.wsdl.extensions.soap.SOAPBinding; > import javax.wsdl.extensions.soap.SOAPBody; > import javax.wsdl.extensions.soap.SOAPOperation; >+import org.eclipse.wst.ws.internal.explorer.platform.perspective.TransportProviderRegistry; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.BindingTypes; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; >@@ -36,6 +39,8 @@ > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.SOAPHeaderWrapperFragment; > import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.WSDLPartsToXSDTypeMapper; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransportProvider; >+import org.eclipse.wst.ws.internal.explorer.transport.MessageContext; > import org.eclipse.wst.wsdl.binding.soap.SOAPHeader; > import org.eclipse.xsd.XSDNamedComponent; > >@@ -55,7 +60,10 @@ > private String encodingStyle_; > private String encodingNamespace_; > >- private Map headerCache = new Hashtable(); >+ private Map headerCache; >+ >+ private MessageContext messageContext = null; >+ private ISOAPTransportProvider soapTransportProvider = null; > > private final void gatherSoapInformation(WSDLBindingElement bindingElement,SOAPBinding soapBinding) > { >@@ -116,6 +124,37 @@ > setOperation(bindingElement,operation); > } > >+ private Definition getDefinition(WSDLBindingElement bindingElement) { >+ WSDLServiceElement serviceElement = (WSDLServiceElement) bindingElement.getParentElement(); >+ WSDLElement wsdlElement = (WSDLElement) serviceElement.getParentElement(); >+ return wsdlElement.getDefinition(); >+ } >+ >+ private void setMessageContext(WSDLBindingElement bindingElement) { >+ messageContext = new MessageContext(); >+ messageContext.setDefinition(getDefinition(bindingElement)); >+ messageContext.setBindingOperation(getBindingOperation(bindingElement)); >+ messageContext.setBindingProtocol(bindingElement.getBindingExtensibilityElement()); >+ messageContext.setDocumentStyle(isDocumentStyle_); >+ } >+ >+ public MessageContext getMessageContext() { >+ return messageContext; >+ } >+ >+ private void setSOAPTransportProvider(SOAPBinding soapBinding) { >+ >+ String namespaceURI = soapBinding.getElementType().getNamespaceURI(); >+ String transportURI = soapBinding.getTransportURI(); >+ >+ soapTransportProvider = TransportProviderRegistry.getInstance() >+ .getSOAPTransportProvider(namespaceURI, transportURI); >+ } >+ >+ public ISOAPTransportProvider getSOAPTransportProvider() { >+ return soapTransportProvider; >+ } >+ > public void setOperation(WSDLBindingElement bindingElement,Operation operation) { > operation_ = operation; > setDocumentation(operation.getDocumentationElement()); >@@ -127,6 +166,9 @@ > { > case BindingTypes.SOAP: > gatherSoapInformation(bindingElement,(SOAPBinding)bindingExtensibilityElement); >+ setMessageContext(bindingElement); >+ setSOAPTransportProvider((SOAPBinding) bindingExtensibilityElement); >+ headerCache = new Hashtable(); > case BindingTypes.HTTP_GET: > case BindingTypes.HTTP_POST: > default: >@@ -255,7 +297,7 @@ > else > id.append(FragmentConstants.OUTPUT_ID).append(soapHeader.getMessage()).append(FragmentConstants.PART_TOKEN); > >- return getFragment(part, id, isInput); // only wrap input header fragments >+ return getFragment(part, id, true, isInput); // only wrap input header fragments > } > > public IXSDFragment getFragment(Part part) { >@@ -269,17 +311,17 @@ > else > id.append(FragmentConstants.OUTPUT_ID); > >- return getFragment(part, id, false); >+ return getFragment(part, id, false, false); > } > >- private IXSDFragment getFragment(Part part, StringBuffer id, boolean useSOAPHeaderWrapper) { >+ private IXSDFragment getFragment(Part part, StringBuffer id, boolean isHeader, boolean useSOAPHeaderWrapper) { > String partName = part.getName(); > id.append(partName); > XSDToFragmentConfiguration config = new XSDToFragmentConfiguration(); > config.setIsWSDLPart(true); > config.setWSDLPartName(partName); > config.setXSDComponent(getSchema(part, id.toString())); >- if (isDocumentStyle()) >+ if (isDocumentStyle() || isHeader) > config.setStyle(FragmentConstants.STYLE_DOCUMENT); > else > config.setStyle(FragmentConstants.STYLE_RPC); >Index: wsexplorer-properties/wsdl.properties >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-properties/wsdl.properties,v >retrieving revision 1.4 >diff -u -r1.4 wsdl.properties >--- wsexplorer-properties/wsdl.properties 28 Mar 2007 13:51:41 -0000 1.4 >+++ wsexplorer-properties/wsdl.properties 18 Apr 2007 18:13:09 -0000 >@@ -1,12 +1,15 @@ > ############################################################################### >-# Copyright (c) 2001, 2004 IBM Corporation and others. >+# Copyright (c) 2001, 2007 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at > # http://www.eclipse.org/legal/epl-v10.html > # > # Contributors: >-# IBM Corporation - initial API and implementation >+# IBM Corporation - initial API and implementation >+# yyyymmdd bug Email and other contact information >+# -------- -------- ----------------------------------------------------------- >+# 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > ############################################################################### > > title=WSDL >@@ -160,3 +163,8 @@ > MSG_ERROR_MIN_OCCURS_VIOLATION=IWAB0391E Minimum occurance is reached. > MSG_ERROR_CANNOT_MOVE_FIRST_ELEMENT_UP=IWAB0392E Selected element is already the first in the group. > MSG_ERROR_CANNOT_MOVE_LAST_ELEMENT_DOWN=IWAB0393E Selected element is already the last in the group. >+ >+# SOAP transport messages >+MSG_ERROR_NO_SUITABLE_TRANSPORT=Failed to invoke operation, a suitable transport extension was not found. >+MSG_ERROR_UNSUPPORTED_BINDING=%1 binding is unsupported. >+MSG_ERROR_UNSUPPORTED_TRANSPORT=%1 transport is unsupported. >Index: wsexplorer/wsdl/forms/FragmentsSoapView.jsp >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer/wsdl/forms/FragmentsSoapView.jsp,v >retrieving revision 1.5 >diff -u -r1.5 FragmentsSoapView.jsp >--- wsexplorer/wsdl/forms/FragmentsSoapView.jsp 28 Mar 2007 13:51:49 -0000 1.5 >+++ wsexplorer/wsdl/forms/FragmentsSoapView.jsp 18 Apr 2007 18:13:09 -0000 >@@ -13,6 +13,7 @@ > * 20060222 127443 jesper@selskabet.org - Jesper S Moller > * 20060726 144824 mahutch@ca.ibm.com - Mark Hutchinson > * 20070305 117034 makandre@ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > %> > <%@ page contentType="text/html; charset=UTF-8" import="org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*, >@@ -22,6 +23,7 @@ > org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.*, > org.eclipse.wst.ws.internal.explorer.platform.constants.*, > org.eclipse.wst.ws.internal.explorer.platform.util.*, >+ org.eclipse.wst.ws.internal.explorer.transport.*, > org.eclipse.wst.wsdl.binding.soap.SOAPHeader, > org.w3c.dom.*, > javax.wsdl.*, >@@ -34,86 +36,56 @@ > <% > WSDLPerspective wsdlPerspective = controller.getWSDLPerspective(); > WSDLOperationElement operElement = (WSDLOperationElement)(wsdlPerspective.getNodeManager().getSelectedNode().getTreeElement()); >- Operation oper = operElement.getOperation(); >- Hashtable soapEnvelopeNamespaceTable = new Hashtable(); >- SoapHelper.addDefaultSoapEnvelopeNamespaces(soapEnvelopeNamespaceTable); >+ ISOAPTransport soapTransport = operElement.getSOAPTransportProvider().newTransport(); >+ ISOAPMessage soapMessage = soapTransport.newMessage(operElement.getMessageContext()); >+ operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOAP_REQUEST_TMP, soapMessage); > >- Iterator it = operElement.getSOAPHeaders().iterator(); >- StringBuffer sourceContentHeader = new StringBuffer(); >- String cachedSourceContent = operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT_HEADER); >- if (cachedSourceContent != null) >- sourceContentHeader.append(cachedSourceContent); >- else >- { >- while (it.hasNext()) >- { >- SOAPHeader soapHeader = (SOAPHeader)it.next(); >- IXSDFragment frag = operElement.getHeaderFragment(soapHeader); >- Element[] instanceDocuments = frag.genInstanceDocumentsFromParameterValues(!operElement.isUseLiteral(), soapEnvelopeNamespaceTable, XMLUtils.createNewDocument(null)); >- for (int i = 0; i < instanceDocuments.length; i++) >- { >- String serializedFragment = XMLUtils.serialize(instanceDocuments[i], true); >- if (serializedFragment == null) >- { >- // On Some JRE's (Sun java 5) elements with an attribute with the xsi >- // prefix do not serialize properly because the namespace can not >- // be found so the string returned comes back as null. To workaround >- // this problem try adding in the namespace declaration attribute >- // and retry the serialization (bug 144824) >- instanceDocuments[i].setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); >- serializedFragment = XMLUtils.serialize(instanceDocuments[i], true); >- } >- >- sourceContentHeader.append(serializedFragment); >- sourceContentHeader.append(HTMLUtils.LINE_SEPARATOR); >- } >- } >- } >+ Hashtable soapEnvelopeNamespaceTable = new Hashtable(soapMessage.getNamespaceTable()); > >- it = operElement.getOrderedBodyParts().iterator(); >- StringBuffer sourceContent = new StringBuffer(); >- cachedSourceContent = operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT); >- if (cachedSourceContent != null) >- { >- sourceContent.append(cachedSourceContent); >- String[] nsDeclarations = (String[])operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE); >- if (nsDeclarations != null) >- { >- for (int i = 0; i < nsDeclarations.length; i++) >- { >- String[] prefix_ns = SoapHelper.decodeNamespaceDeclaration(nsDeclarations[i]); >- if (!soapEnvelopeNamespaceTable.contains(prefix_ns[1])) >- soapEnvelopeNamespaceTable.put(prefix_ns[1], prefix_ns[0]); >- } >- } >+ String cachedHeaderContent = operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT_HEADER); >+ String cachedBodyContent = operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT); >+ >+ // if either header or body has been cached, need to ensure namespace table is updated >+ // from the cached copy >+ if (cachedHeaderContent != null || cachedBodyContent != null) { >+ if (SOAPMessageUtils.decodeNamespaceTable(soapEnvelopeNamespaceTable, operElement)) >+ soapMessage.setNamespaceTable(soapEnvelopeNamespaceTable); > } >- else >- { >- while (it.hasNext()) >- { >- Part part = (Part)it.next(); >- IXSDFragment frag = operElement.getFragment(part); >- Element[] instanceDocuments = frag.genInstanceDocumentsFromParameterValues(!operElement.isUseLiteral(), soapEnvelopeNamespaceTable, XMLUtils.createNewDocument(null)); >- for (int i = 0; i < instanceDocuments.length; i++) >- { >- String serializedFragment = XMLUtils.serialize(instanceDocuments[i], true); >- if (serializedFragment == null) >- { >- // On Some JRE's (Sun java 5) elements with an attribute with the xsi >- // prefix do not serialize properly because the namespace can not >- // be found so the string returned comes back as null. To workaround >- // this problem try adding in the namespace declaration attribute >- // and retry the serialization (bug 144824) >- instanceDocuments[i].setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); >- serializedFragment = XMLUtils.serialize(instanceDocuments[i], true); >- } >- >- sourceContent.append(serializedFragment); >- sourceContent.append(HTMLUtils.LINE_SEPARATOR); >- } >- } >+ >+ String headerContent; >+ String bodyContent; >+ >+ if (cachedHeaderContent != null) >+ headerContent = cachedHeaderContent; >+ else { >+ try { >+ SOAPMessageUtils.setHeaderContentFromModel(soapEnvelopeNamespaceTable, operElement, soapMessage); >+ >+ // ensure namespace table updated in message before serialize operation >+ soapMessage.setNamespaceTable(soapEnvelopeNamespaceTable); >+ headerContent = soapTransport.newSerializer().serialize(ISOAPMessage.HEADER_CONTENT, soapMessage); >+ } >+ catch (Exception e) { >+ headerContent = ""; >+ } > } >- >+ >+ if (cachedBodyContent != null) >+ bodyContent = cachedBodyContent; >+ else { >+ try { >+ SOAPMessageUtils.setBodyContentFromModel(soapEnvelopeNamespaceTable, operElement, soapMessage); >+ >+ // ensure namespace table updated in message before serialize operation >+ soapMessage.setNamespaceTable(soapEnvelopeNamespaceTable); >+ bodyContent = soapTransport.newSerializer().serialize(ISOAPMessage.BODY_CONTENT, soapMessage); >+ } >+ catch (Exception e) { >+ bodyContent = ""; >+ } >+ } >+ >+ // cache the namespace table > Enumeration enm = soapEnvelopeNamespaceTable.keys(); > while (enm.hasMoreElements()) > { >@@ -129,8 +101,7 @@ > <tr> > <td height=30 valign="bottom" class="labels"> > <% >- Document doc = XMLUtils.createNewDocument(null); >- Element soapEnvelopeElement = SoapHelper.createSoapEnvelopeElement(doc,soapEnvelopeNamespaceTable); >+ Element soapEnvelopeElement = soapMessage.getEnvelope(false); > StringBuffer header = new StringBuffer("<"); > header.append(soapEnvelopeElement.getTagName()); > NamedNodeMap attributes = soapEnvelopeElement.getAttributes(); >@@ -163,8 +134,8 @@ > </table> > <% > } >- >- Element soapHeaderElement = SoapHelper.createSoapHeaderElement(doc); >+ >+ Element soapHeaderElement = soapMessage.getHeader(false); > header.setLength(0); > header.append('<').append(soapHeaderElement.getTagName()); > attributes = soapHeaderElement.getAttributes(); >@@ -226,7 +197,7 @@ > <img width="16" height="16" src="<%=response.encodeURL(controller.getPathWithContext("images/space.gif"))%>"> > </td> > <td width="100%"> >- <textarea id="soap_header_content" name="<%=FragmentConstants.SOURCE_CONTENT_HEADER%>" class="textareaenter"><%=HTMLUtils.charactersToHTMLEntitiesStrict(sourceContentHeader.toString())%></textarea> >+ <textarea id="soap_header_content" name="<%=FragmentConstants.SOURCE_CONTENT_HEADER%>" class="textareaenter"><%=HTMLUtils.charactersToHTMLEntitiesStrict(headerContent)%></textarea> > </td> > </tr> > </table> >@@ -245,7 +216,7 @@ > </tr> > </table> > <% >- Element soapBodyElement = SoapHelper.createSoapBodyElement(doc); >+ Element soapBodyElement = soapMessage.getBody(false); > header.setLength(0); > header.append('<').append(soapBodyElement.getTagName()); > attributes = soapBodyElement.getAttributes(); >@@ -287,51 +258,9 @@ > > Element wrapperElement = null; > if (!operElement.isDocumentStyle()) >- { >- // Must be RPC style. >- String encodingNamespaceURI = null; >- /* >- * WS-I: In a rpc-literal SOAP binding, the serialized child element of the >- * soap:Body element consists of a wrapper element, whose namespace is the value >- * of the namespace attribute of the soapbind:body element and whose local name is >- * either the name of the operation or the name of the operation suffixed >- * with "Response". The namespace attribute is required, as opposed to being >- * optional, to ensure that the children of the soap:Body element are namespace- >- * qualified. >- */ >- BindingOperation bindingOperation = operElement.getBindingOperation(); >- if (bindingOperation != null) >- { >- BindingInput bindingInput = bindingOperation.getBindingInput(); >- if (bindingInput != null) >- { >- List extElements = bindingInput.getExtensibilityElements(); >- for (Iterator extElementsIt = extElements.iterator(); extElementsIt.hasNext();) >- { >- ExtensibilityElement extElement = (ExtensibilityElement)extElementsIt.next(); >- if (extElement instanceof SOAPBody) >- { >- encodingNamespaceURI = ((SOAPBody)extElement).getNamespaceURI(); >- break; >- } >- } >- } >- } >- // If the namespace of the soapbind:body element is not set, get it from the operation element >- if (encodingNamespaceURI == null) >- encodingNamespaceURI = operElement.getEncodingNamespace(); >- // If the namespace of the operation element is not set, get it from the definition element >- if (encodingNamespaceURI == null) >- { >- WSDLBindingElement bindingElement = (WSDLBindingElement)operElement.getParentElement(); >- WSDLServiceElement serviceElement = (WSDLServiceElement)bindingElement.getParentElement(); >- WSDLElement wsdlElement = (WSDLElement)serviceElement.getParentElement(); >- Definition definition = wsdlElement.getDefinition(); >- encodingNamespaceURI = definition.getTargetNamespace(); >- } >- // Generate an RPC style wrapper element. >- String encodingStyle = (operElement.isUseLiteral() ? null : operElement.getEncodingStyle()); >- wrapperElement = SoapHelper.createRPCWrapperElement(doc,soapEnvelopeNamespaceTable,encodingNamespaceURI,oper.getName(),encodingStyle); >+ { >+ // Generate an RPC style wrapper element. >+ wrapperElement = (Element) soapBodyElement.getFirstChild(); > header.setLength(0); > header.append('<').append(wrapperElement.getTagName()); > attributes = wrapperElement.getAttributes(); >@@ -398,7 +327,7 @@ > <img width=<%=sourceContentIndentationImageWidth%> height=16 src="<%=response.encodeURL(controller.getPathWithContext("images/space.gif"))%>"> > </td> > <td width="100%"> >- <textarea id="soap_body_content" name="<%=FragmentConstants.SOURCE_CONTENT%>" class="bigtextareaenter"><%=HTMLUtils.charactersToHTMLEntitiesStrict(sourceContent.toString())%></textarea> >+ <textarea id="soap_body_content" name="<%=FragmentConstants.SOURCE_CONTENT%>" class="bigtextareaenter"><%=HTMLUtils.charactersToHTMLEntitiesStrict(bodyContent)%></textarea> > </td> > </tr> > </table> >Index: wsexplorer/wsdl/forms/ReadOnlyFragmentsFormView.jsp >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer/wsdl/forms/ReadOnlyFragmentsFormView.jsp,v >retrieving revision 1.2 >diff -u -r1.2 ReadOnlyFragmentsFormView.jsp >--- wsexplorer/wsdl/forms/ReadOnlyFragmentsFormView.jsp 28 Mar 2007 13:51:50 -0000 1.2 >+++ wsexplorer/wsdl/forms/ReadOnlyFragmentsFormView.jsp 18 Apr 2007 18:13:09 -0000 >@@ -11,6 +11,7 @@ > * yyyymmdd bug Email and other contact information > * -------- -------- ----------------------------------------------------------- > * 20070305 117034 makandre@ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > %> > <%@ page contentType="text/html; charset=UTF-8" import="org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*, >@@ -19,10 +20,12 @@ > org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*, > org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.*, > org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.*, >+ org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.*, > org.eclipse.wst.ws.internal.explorer.platform.constants.*, > org.eclipse.wst.ws.internal.explorer.platform.perspective.Node, > org.eclipse.wst.ws.internal.explorer.platform.perspective.*, > org.eclipse.wst.ws.internal.explorer.platform.util.*, >+ org.eclipse.wst.ws.internal.explorer.transport.*, > org.eclipse.wst.wsdl.binding.soap.SOAPHeader, > org.w3c.dom.*, > javax.wsdl.*, >@@ -32,136 +35,6 @@ > <jsp:useBean id="controller" class="org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller" scope="session"/> > <jsp:useBean id="fragID" class="java.lang.StringBuffer" scope="request"/> > <jsp:useBean id="nodeID" class="java.lang.StringBuffer" scope="request"/> >- >-<%! >-private Element soapResponse_ = null; >-private boolean hasSOAPHeaders = false; >- >-private void checkSOAPHeaders() { >- >- NodeList nl = soapResponse_.getElementsByTagNameNS(FragmentConstants.URI_SOAP_ENV, FragmentConstants.QNAME_LOCAL_NAME_HEADER); >- if (nl.getLength() == 0) >- return; >- >- Element soapHeader = (Element) nl.item(0); >- NodeList nodes = soapHeader.getChildNodes(); >- >- for (int i = 0; i < nodes.getLength(); i++) { >- if (nodes.item(i) instanceof Element) { >- hasSOAPHeaders = true; >- return; >- } >- } >-} >- >-private Element[] parseSOAPResponse(SOAPMessageQueue soapMessageQueue, WSDLOperationElement operElement) >-{ >- String messages = soapMessageQueue.getMessagesFromList(); >- try >- { >- soapResponse_ = XMLUtils.stringToElement(messages, true); >- checkSOAPHeaders(); >- NodeList nl = soapResponse_.getElementsByTagNameNS(FragmentConstants.URI_SOAP_ENV, FragmentConstants.QNAME_LOCAL_NAME_BODY); >- if (nl.getLength() > 0) >- { >- Element soapBody = (Element)nl.item(0); >- NodeList soapFault = soapBody.getElementsByTagNameNS(FragmentConstants.URI_SOAP_ENV, FragmentConstants.QNAME_LOCAL_NAME_FAULT); >- if (soapFault.getLength() > 0) >- return new Element[0]; >- NodeList instanceList; >- if (operElement.isDocumentStyle()) >- instanceList = soapBody.getChildNodes(); >- else >- { >- NodeList rpcWrapper = soapBody.getElementsByTagNameNS("*", operElement.getOperation().getOutput().getMessage().getQName().getLocalPart()); >- >- /* >- * HACK - Some of the web services out on the internet do not >- * set their RPC wrapper properly. It should be set to the output >- * message name of the selected operation. The hack is to >- * assume the first element inside the body element is the >- * RPC wrapper. >- */ >- if (rpcWrapper.getLength() <= 0) >- rpcWrapper = soapBody.getElementsByTagNameNS("*", "*"); >- >- if (rpcWrapper.getLength() > 0) >- instanceList = rpcWrapper.item(0).getChildNodes(); >- else >- return null; >- } >- return fixSOAPResponse(instanceList, operElement); >- } >- } >- catch (Throwable t) { >- t.printStackTrace(); >- } >- return null; >-} >- >-/* >-* HACK - The root element tag name of the instance document >-* is ambiguous. It lands on a very grey area between the SOAP >-* spec and the WSDL spec. The two specs do not explicitly define >-* that the root element tag name must match the name of the >-* WSDL part. The hack is to treat elements with different tag names >-* as instances of the WSDL part. >-*/ >-private Element[] fixSOAPResponse(NodeList instanceList, WSDLOperationElement operElement) >-{ >- Vector instanceVector = new Vector(); >- for (int i = 0; i < instanceList.getLength(); i++) >- { >- Object object = instanceList.item(i); >- if (object != null && (object instanceof Element)) >- instanceVector.add(object); >- } >- Element[] instanceDocuments = new Element[instanceVector.size()]; >- Operation oper = operElement.getOperation(); >- Map partsMap = oper.getOutput().getMessage().getParts(); >- if (partsMap.size() == 1) >- { >- Iterator it = partsMap.values().iterator(); >- IXSDFragment frag = operElement.getFragment((Part)it.next(), false); >- for (int i = 0; i < instanceVector.size(); i++) >- { >- Element element = (Element)instanceVector.get(i); >- if (!element.getTagName().equals(frag.getName())) >- { >- Document doc = element.getOwnerDocument(); >- NodeList children = element.getChildNodes(); >- NamedNodeMap attributes = element.getAttributes(); >- element = doc.createElement(frag.getName()); >- for (int j = 0; j < children.getLength(); j++) >- { >- if (children.item(j) != null) >- { >- element.appendChild(children.item(j)); >- // When you append a node from one element to another, >- // the original element will lose its reference to this node, >- // therefore, the size of the node list will decrease by 1. >- j--; >- } >- } >- for (int j = 0; j < attributes.getLength(); j++) >- { >- Object attr = attributes.item(j); >- if (attr != null && (attr instanceof Attr)) >- { >- Attr attribute = (Attr)attr; >- element.setAttribute(attribute.getName(), attribute.getValue()); >- } >- } >- } >- instanceDocuments[i] = element; >- } >- } >- else >- instanceVector.copyInto(instanceDocuments); >- return instanceDocuments; >-} >-%> >- > <% > WSDLPerspective wsdlPerspective = controller.getWSDLPerspective(); > wsdlPerspective.setStatusContentType(WSDLPerspective.STATUS_CONTENT_RESULT_FORM); >@@ -184,14 +57,13 @@ > } > else > { >+ ISOAPMessage soapMessage = (ISOAPMessage) operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOAP_RESPONSE); >+ Element[] headerContent = soapMessage.getHeaderContent();; >+ Element[] bodyContent = soapMessage.getBodyContent(); >+ > boolean cached = ((Boolean)operElement.getPropertyAsObject(WSDLActionInputs.SOAP_RESPONSE_CACHED)).booleanValue(); >- Element[] instanceDocuments = null; >- if (!cached) >- { >- SOAPMessageQueue soapMessageQueue = wsdlPerspective.getSOAPResponseQueue(); >- instanceDocuments = parseSOAPResponse(soapMessageQueue, operElement); >- } >- if (!cached && !hasSOAPHeaders && instanceDocuments == null) >+ >+ if (soapMessage.getBody(false) == null) // body is mandatory > { > %> > <table width="95%" border=0 cellpadding=6 cellspacing=0> >@@ -203,7 +75,8 @@ > </table> > <% > } >- else if (!cached && !hasSOAPHeaders && instanceDocuments.length <= 0) >+ else if ((headerContent == null || headerContent.length == 0) && >+ (soapMessage.getFault() != null || bodyContent == null || bodyContent.length == 0)) > { > %> > <table width="95%" border=0 cellpadding=6 cellspacing=0> >@@ -237,31 +110,40 @@ > > <div id="<%=headerDivId%>" class="fragarea"> > <% >- if (cached || hasSOAPHeaders) { >- hasSOAPHeaders = false; >+ boolean hasSOAPHeaders = false; >+ if (headerContent != null && headerContent.length > 0) { >+ > Iterator it = operElement.getSOAPHeaders(false).iterator(); >- while (it.hasNext()) { >- SOAPHeader soapHeader = (SOAPHeader) it.next(); >- String ns = soapHeader.getEPart().getElementDeclaration().getTargetNamespace(); >- IXSDFragment frag = operElement.getHeaderFragment(soapHeader, false); >+ int start = 0; >+ while (it.hasNext() && start < headerContent.length) { >+ SOAPHeader soapHeader = (SOAPHeader) it.next(); >+ IXSDFragment fragment = operElement.getHeaderFragment(soapHeader, false); > >- if (!cached) { >- NodeList nl = soapResponse_.getElementsByTagNameNS(ns, frag.getName()); >- if (nl.getLength() == 0) >+ if (!cached) { >+ int pos = SOAPMessageUtils.findFirstMatchingElement( >+ soapHeader.getEPart(), >+ headerContent, >+ soapMessage.getNamespaceTable(), >+ fragment.getName(), >+ start); >+ >+ if (pos == -1) > continue; > >- Element element = (Element) nl.item(0); >- if (!frag.setParameterValuesFromInstanceDocuments(new Element[] { element })) >+ Element element = headerContent[pos]; >+ start = pos + 1; >+ >+ if (!fragment.setParameterValuesFromInstanceDocuments(new Element[] { element })) > continue; > } >- else if (!frag.validateAllParameterValues()) >+ else if (!fragment.validateAllParameterValues()) > continue; > > hasSOAPHeaders = true; > fragID.delete(0, fragID.length()); >- fragID.append(frag.getID()); >+ fragID.append(fragment.getID()); > %> >- <jsp:include page="<%=frag.getReadFragment()%>" flush="true"/> >+ <jsp:include page="<%=fragment.getReadFragment()%>" flush="true"/> > <% > } > } >@@ -294,8 +176,9 @@ > > <div id="<%=bodyDivId%>" class="fragarea"> > <% >- if (cached || (instanceDocuments != null && instanceDocuments.length > 0)) { >- >+ boolean hasSOAPBody = false; >+ if (bodyContent != null && bodyContent.length > 0) { >+ > Map partsMap = oper.getOutput().getMessage().getParts(); > Iterator it = partsMap.values().iterator(); > Hashtable uriReferences = null; >@@ -307,11 +190,16 @@ > if (!operElement.isUseLiteral() && (fragment instanceof ISOAPEncodingWrapperFragment)) > { > if (uriReferences == null) >- uriReferences = SOAPEncodingWrapperFragment.parseURIReferences(soapResponse_, true); >+ uriReferences = SOAPEncodingWrapperFragment.parseURIReferences(soapMessage.getEnvelope(true), true); > ((ISOAPEncodingWrapperFragment)fragment).setURIReferences(uriReferences); > } >- fragment.setParameterValuesFromInstanceDocuments(instanceDocuments); >+ if (!fragment.setParameterValuesFromInstanceDocuments(bodyContent)) >+ continue; > } >+ else if (!fragment.validateAllParameterValues()) >+ continue; >+ >+ hasSOAPBody = true; > fragID.delete(0, fragID.length()); > fragID.append(fragment.getID()); > %> >@@ -320,7 +208,7 @@ > } > operElement.setPropertyAsObject(WSDLActionInputs.SOAP_RESPONSE_CACHED, new Boolean(true)); > } >- else { >+ if (!hasSOAPBody) { > %> > <table width="95%" border=0 cellpadding=6 cellspacing=0> > <tr> >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLModelConstants.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLModelConstants.java,v >retrieving revision 1.2 >diff -u -r1.2 WSDLModelConstants.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLModelConstants.java 28 Mar 2007 13:51:41 -0000 1.2 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLModelConstants.java 18 Apr 2007 18:13:09 -0000 >@@ -10,6 +10,7 @@ > * yyyymmdd bug Email and other contact information > * -------- -------- ----------------------------------------------------------- > * 20070305 117034 makandre@ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > > package org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants; >@@ -29,4 +30,9 @@ > public final static String PROP_SOURCE_CONTENT_HEADER = "propSourceContentHeader"; > public final static String PROP_SOURCE_CONTENT = "propSourceContent"; > public final static String PROP_SOURCE_CONTENT_NAMESPACE = "propSourceContentNS"; >+ >+ // Transport >+ public final static String PROP_SOAP_REQUEST_TMP = "propSOAPRequestTmp"; >+ public final static String PROP_SOAP_REQUEST = "propSOAPRequest"; >+ public final static String PROP_SOAP_RESPONSE = "propSOAPResponse"; > } >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SoapHelper.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SoapHelper.java,v >retrieving revision 1.3 >diff -u -r1.3 SoapHelper.java >--- wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SoapHelper.java 28 Mar 2007 13:51:50 -0000 1.3 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SoapHelper.java 18 Apr 2007 18:13:09 -0000 >@@ -10,6 +10,7 @@ > * yyyymmdd bug Email and other contact information > * -------- -------- ----------------------------------------------------------- > * 20070305 117034 makandre@ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable > *******************************************************************************/ > > package org.eclipse.wst.ws.internal.explorer.platform.wsdl.util; >@@ -96,6 +97,10 @@ > break; > nsId++; > } while (true); >+ >+ // need to ensure whatever prefix we choose is added to the namespace table >+ // so that it will not be reused lated on >+ soapEnvelopeNamespaceTable.put(encodingNamespaceURI, wrapperElementName.toString()); > } > String wrapperElementNamePrefix = wrapperElementName.toString(); > wrapperElementName.append(':').append(operationName); >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/wst/components/ws/plugins/org.eclipse.wst.ws.explorer/META-INF/MANIFEST.MF,v >retrieving revision 1.32 >diff -u -r1.32 MANIFEST.MF >--- META-INF/MANIFEST.MF 29 Mar 2007 01:49:08 -0000 1.32 >+++ META-INF/MANIFEST.MF 18 Apr 2007 18:13:09 -0000 >@@ -4,14 +4,16 @@ > Bundle-SymbolicName: org.eclipse.wst.ws.explorer; singleton:=true > Bundle-Version: 1.0.204.qualifier > Bundle-ClassPath: explorer.jar, >- wsexplorer-properties.jar >+ wsexplorer-properties.jar, >+ wsexplorer/WEB-INF/lib/wsexplorer.jar > Bundle-Activator: org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin > Bundle-Vendor: %PLUGIN_PROVIDER > Bundle-Localization: plugin > Export-Package: org.eclipse.wst.ws.internal.explorer;x-internal:=true, > org.eclipse.wst.ws.internal.explorer.favorites;x-internal:=true, > org.eclipse.wst.ws.internal.explorer.plugin;x-internal:=true, >- org.eclipse.wst.ws.internal.explorer.popup;x-internal:=true >+ org.eclipse.wst.ws.internal.explorer.popup;x-internal:=true, >+ org.eclipse.wst.ws.internal.explorer.transport;x-internal:=true > Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", > org.eclipse.core.resources;bundle-version="[3.2.0,3.4.0)", > org.eclipse.help.appserver;bundle-version="[3.1.100,3.2.0)", >Index: src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransportProvider.java >=================================================================== >RCS file: src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransportProvider.java >diff -N src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransportProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransportProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.transport; >+ >+/** >+ * ISOAPTransportProvider is a factory for creating ISOAPTransport objects. >+ * Anyone who wishes to extend the org.eclipse.wst.ws.explorer.wseTransportProvider >+ * extension-point must provide an implementation for this interface. >+ */ >+public interface ISOAPTransportProvider { >+ >+ /** >+ * Method for obtaining a new ISOAPTransport from this provider. >+ * This method should never return null. >+ * >+ * @return A new ISOAPTransport object. >+ */ >+ public ISOAPTransport newTransport(); >+} >Index: src/org/eclipse/wst/ws/internal/explorer/transport/TransportException.java >=================================================================== >RCS file: src/org/eclipse/wst/ws/internal/explorer/transport/TransportException.java >diff -N src/org/eclipse/wst/ws/internal/explorer/transport/TransportException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/ws/internal/explorer/transport/TransportException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.transport; >+ >+/** >+ * An general purpose exception to indicate a problem has occurred when >+ * invoking a web service. >+ */ >+public class TransportException extends RuntimeException { >+ >+ private static final long serialVersionUID = -1502247230726021403L; >+ >+ /** >+ * Constructor. >+ * >+ * @param message A message about the problem that occurred. >+ */ >+ public TransportException(String message) { >+ super(message); >+ } >+ >+ /** >+ * Constructor that accepts a message and a cause. >+ * >+ * @param message A message about the problem that occurred. >+ * @param cause The cause for this exception. >+ */ >+ public TransportException(String message, Throwable cause) { >+ super(message, cause); >+ } >+ >+ /** >+ * Constructor that accepts a cause. >+ * >+ * @param cause The cause for this exception. >+ */ >+ public TransportException(Throwable cause) { >+ super(cause); >+ } >+} >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SOAPMessageUtils.java >=================================================================== >RCS file: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SOAPMessageUtils.java >diff -N wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SOAPMessageUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SOAPMessageUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,172 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.platform.wsdl.util; >+ >+import java.util.Hashtable; >+import java.util.Iterator; >+import java.util.Map; >+import java.util.Vector; >+ >+import javax.wsdl.Part; >+import javax.xml.parsers.ParserConfigurationException; >+ >+import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLModelConstants; >+import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement; >+import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage; >+import org.eclipse.wst.wsdl.binding.soap.SOAPHeader; >+import org.w3c.dom.Element; >+ >+/** >+ * This class has some common routines used by the Web Services explorer to work with ISOAPMessages. >+ */ >+public class SOAPMessageUtils { >+ >+ /** >+ * Decodes namespace declarations that have been encoded by WSE into the operation element of the WSDL model. >+ * The decoded declarations will be added to the given namespace table. >+ * >+ * @param soapEnvelopeNamespaceTable The namespace table to populate. >+ * @param operElement The operation element with the encoded namespace declarations. >+ * @return True if new namespace declarations are found and added to the namespace table, false otherwise. >+ */ >+ public static boolean decodeNamespaceTable(Hashtable soapEnvelopeNamespaceTable, WSDLOperationElement operElement) { >+ >+ boolean updated = false; >+ >+ String[] nsDeclarations = (String[]) operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE); >+ if (nsDeclarations == null) >+ return false; >+ >+ // each namespace declaration is decoded into 2 parts: the prefix >+ // in element [0] and the namespace uri in element [1]. >+ for (int i = 0; i < nsDeclarations.length; i++) { >+ String[] prefix_ns = SoapHelper.decodeNamespaceDeclaration(nsDeclarations[i]); >+ >+ // check if the namespace uri is already a key in the namespace table >+ // if it is, don't add it >+ if (!soapEnvelopeNamespaceTable.containsKey(prefix_ns[1])) { >+ soapEnvelopeNamespaceTable.put(prefix_ns[1], prefix_ns[0]); >+ updated = true; >+ } >+ } >+ >+ return updated; >+ } >+ >+ /** >+ * Populate the header content of the given ISOAPMessage using the values from WSE's fragment model >+ * >+ * @param soapEnvelopeNamespaceTable A namespace table to use during this operation. >+ * @param operElement Access WSE's fragments via this operation element. >+ * @param soapMessage The ISOAPMessage to populate. >+ * @throws ParserConfigurationException >+ */ >+ public static void setHeaderContentFromModel(Hashtable soapEnvelopeNamespaceTable, WSDLOperationElement operElement, ISOAPMessage soapMessage) >+ throws ParserConfigurationException { >+ >+ Vector headerEntries = new Vector(); >+ >+ Iterator it = operElement.getSOAPHeaders().iterator(); >+ while (it.hasNext()) { >+ SOAPHeader soapHeader = (SOAPHeader) it.next(); >+ boolean isUseLiteral = "literal".equals(soapHeader.getUse()); >+ IXSDFragment frag = (IXSDFragment) operElement.getHeaderFragment(soapHeader); >+ Element[] instanceDocuments = frag.genInstanceDocumentsFromParameterValues( >+ !isUseLiteral, soapEnvelopeNamespaceTable, soapMessage.getEnvelope(false).getOwnerDocument()); >+ for (int i = 0; i < instanceDocuments.length; i++) { >+ if (instanceDocuments[i] == null) >+ continue; >+ headerEntries.addElement(instanceDocuments[i]); >+ } >+ } >+ >+ Element[] headerContent = new Element[headerEntries.size()]; >+ headerEntries.copyInto(headerContent); >+ >+ soapMessage.setHeaderContent(headerContent); >+ } >+ >+ /** >+ * Populate the body content of the given ISOAPMessage using the values from WSE's fragment model >+ * >+ * @param soapEnvelopeNamespaceTable A namespace table to use during this operation. >+ * @param operElement Access WSE's fragments via this operation element. >+ * @param soapMessage The ISOAPMessage to populate. >+ * @throws ParserConfigurationException >+ */ >+ public static void setBodyContentFromModel(Hashtable soapEnvelopeNamespaceTable, WSDLOperationElement operElement, ISOAPMessage soapMessage) >+ throws ParserConfigurationException { >+ >+ Vector bodyEntries = new Vector(); >+ boolean isUseLiteral = operElement.isUseLiteral(); >+ >+ Iterator it = operElement.getOrderedBodyParts().iterator(); >+ while (it.hasNext()) { >+ Part part = (Part)it.next(); >+ IXSDFragment frag = (IXSDFragment) operElement.getFragment(part); >+ Element[] instanceDocuments = frag.genInstanceDocumentsFromParameterValues( >+ !isUseLiteral, soapEnvelopeNamespaceTable, soapMessage.getEnvelope(false).getOwnerDocument()); >+ for (int i = 0; i < instanceDocuments.length; i++) { >+ if (instanceDocuments[i] == null) >+ continue; >+ bodyEntries.addElement(instanceDocuments[i]); >+ } >+ } >+ >+ Element[] bodyContent = new Element[bodyEntries.size()]; >+ bodyEntries.copyInto(bodyContent); >+ >+ soapMessage.setBodyContent(bodyContent); >+ } >+ >+ /** >+ * Given an array of elements, this method will return the index of the first element that matches >+ * the given Part. A match is determined by comparing the fully qualified names of the Part and Elements. >+ * >+ * @param part The Part >+ * @param elements The array of Elements >+ * @param namespaceTable A namespace table for looking up namespace prefixes. >+ * @param fragName Name of the Part's fragment (essentially the Part's local name). >+ * @param start The index to begin the search. >+ * @return The index of the first matching element, or -1 if no match is found. >+ */ >+ public static int findFirstMatchingElement(Part part, Element[] elements, Map namespaceTable, String fragName, int start) { >+ >+ String namespaceURI = null; >+ String prefix = null; >+ >+ // try to get the prefix >+ if (part.getElementName() != null) { >+ namespaceURI = part.getElementName().getNamespaceURI(); >+ prefix = (String) namespaceTable.get(namespaceURI); >+ } >+ >+ for (int i = start; i < elements.length; i++) { >+ Element element = elements[i]; >+ String name = element.getTagName(); >+ >+ // try to get prefix again, the namespace declaration can be directly on the element >+ if (prefix == null && namespaceURI != null) >+ prefix = element.lookupPrefix(namespaceURI); >+ >+ if (prefix == null && name.equals(fragName)) >+ return i; >+ else if (prefix != null && name.equals(prefix + ":" + fragName)) >+ return i; >+ } >+ >+ return -1; >+ } >+} >Index: src/org/eclipse/wst/ws/internal/explorer/transport/MessageContext.java >=================================================================== >RCS file: src/org/eclipse/wst/ws/internal/explorer/transport/MessageContext.java >diff -N src/org/eclipse/wst/ws/internal/explorer/transport/MessageContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/ws/internal/explorer/transport/MessageContext.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,107 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.transport; >+ >+import javax.wsdl.BindingOperation; >+import javax.wsdl.Definition; >+import javax.wsdl.extensions.ExtensibilityElement; >+ >+/** >+ * A MessageContext object holds information about the message that is to be >+ * sent on a web service invocation. This information is passed to the >+ * ISOAPTransport so that it can construct an appropriate ISOAPMessage to >+ * handle the invocation. >+ */ >+public class MessageContext { >+ >+ private Definition definition; >+ private ExtensibilityElement bindingProtocol; >+ private BindingOperation bindingOperation; >+ private boolean documentStyle; >+ >+ /** >+ * Sets a reference to the WSDL definition. >+ * >+ * @param definition The WSDL definition. >+ */ >+ public void setDefinition(Definition definition) { >+ this.definition = definition; >+ } >+ >+ /** >+ * Returns the WSDL definition. >+ * >+ * @return The WSDL definition. >+ */ >+ public Definition getDefinition() { >+ return definition; >+ } >+ >+ /** >+ * Sets a reference to the binding extensibility element in the WSDL document. >+ * For a web service that uses the SOAP protocol, this will be an instance of >+ * javax.wsdl.extensions.soap.SOAPBinding >+ * >+ * @param bindingProtocol The binding extensibility element. >+ */ >+ public void setBindingProtocol(ExtensibilityElement bindingProtocol) { >+ this.bindingProtocol = bindingProtocol; >+ } >+ >+ /** >+ * Returns the binding extensibility element. >+ * >+ * @return The binding extensibility element. >+ */ >+ public ExtensibilityElement getBindingProtocol() { >+ return bindingProtocol; >+ } >+ >+ /** >+ * Sets a reference to the binding operation element in the WSDL document. >+ * >+ * @param bindingOperation The binding operation element. >+ */ >+ public void setBindingOperation(BindingOperation bindingOperation) { >+ this.bindingOperation = bindingOperation; >+ } >+ >+ /** >+ * Returns the binding operation element. >+ * >+ * @return The binding operation element. >+ */ >+ public BindingOperation getBindingOperation() { >+ return bindingOperation; >+ } >+ >+ /** >+ * Sets the flag on whether the message created from this MessageContext >+ * is document style or not. >+ * >+ * @param documentStyle True for document style, false otherwise. >+ */ >+ public void setDocumentStyle(boolean documentStyle) { >+ this.documentStyle = documentStyle; >+ } >+ >+ /** >+ * Returns the document style property. >+ * >+ * @return The document style property. >+ */ >+ public boolean isDocumentStyle() { >+ return documentStyle; >+ } >+} >Index: src/org/eclipse/wst/ws/internal/explorer/transport/HTTPTransportException.java >=================================================================== >RCS file: src/org/eclipse/wst/ws/internal/explorer/transport/HTTPTransportException.java >diff -N src/org/eclipse/wst/ws/internal/explorer/transport/HTTPTransportException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/ws/internal/explorer/transport/HTTPTransportException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.transport; >+ >+import java.util.Map; >+ >+/** >+ * A type of TransportException that can be thrown when the transport protocol >+ * is HTTP. The status code of the HTTP response is captured in this >+ * exception and passed up to the Web Services Explorer. >+ */ >+public class HTTPTransportException extends TransportException { >+ >+ private static final long serialVersionUID = 8277180731798858877L; >+ >+ private int statusCode; >+ private Map headers; >+ >+ /** >+ * Constructor. >+ * >+ * @param statusCode The HTTP status code. >+ * @param message A message about the problem that occurred. >+ * @param headers A map of the HTTP headers. >+ */ >+ public HTTPTransportException(int statusCode, String message, Map headers) { >+ super(message); >+ this.statusCode = statusCode; >+ this.headers = headers; >+ } >+ >+ /** >+ * Returns the HTTP status code used to create this exception. >+ * >+ * @return The HTTP status code. >+ */ >+ public int getStatusCode() { >+ return statusCode; >+ } >+ >+ /** >+ * Retrieve the HTTP header for the given key >+ * >+ * @param key The key value. >+ * @return The HTTP header value for key, or null if there is no such header. >+ */ >+ public String getHeader(String key) { >+ Object value = headers.get(key); >+ if (value != null) >+ return value.toString(); >+ else >+ return null; >+ } >+} >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPTransportProvider.java >=================================================================== >RCS file: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPTransportProvider.java >diff -N wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPTransportProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPTransportProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; >+ >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransport; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransportProvider; >+ >+/** >+ * WSE's default implementation for ISOAPTransportProvider. >+ */ >+public class SOAPTransportProvider implements ISOAPTransportProvider { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransportProvider#newTransport() >+ */ >+ public ISOAPTransport newTransport() { >+ return new SOAPTransport(); >+ } >+} >Index: src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPMessage.java >=================================================================== >RCS file: src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPMessage.java >diff -N src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPMessage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPMessage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,220 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.transport; >+ >+import java.util.Map; >+ >+import org.w3c.dom.Element; >+ >+/** >+ * The ISOAPMessage represents a SOAP message in a web service invocation made by the >+ * Web Services Explorer's transport stack. >+ * <br/> >+ * <br/> >+ * The setters of ISOAPMessage are called by Web Services Explorer to populate the >+ * message before sending. WSE does not guarantee that all message elements it sets >+ * will have the same owner document. >+ */ >+public interface ISOAPMessage { >+ >+ /** >+ * ISOAPMessage defines this property for storing the SOAP action value in >+ * a web service invocation. This property will be set by Web Services Explorer >+ * prior to passing the message to {@link ISOAPTransport#send(String, String, String, ISOAPMessage)} >+ */ >+ String PROP_SOAP_ACTION = "prop_soap_action"; >+ >+ /** >+ * This value is used when serializing and deserializing a message. It indicates the operation >+ * is working with the entire SOAP envelope element. >+ */ >+ int ENVELOPE = 0; >+ >+ /** >+ * This value is used when serializing and deserializing a message. It indicates the operation >+ * is working with the elements inside the SOAP header element. >+ */ >+ int HEADER_CONTENT = 1; >+ >+ /** >+ * This value is used when serializing and deserializing a message. It indicates the operation >+ * is working with the elements inside the SOAP body element. >+ */ >+ int BODY_CONTENT = 2; >+ >+ /** >+ * Returns the MessageContext associated with this message. The MessageContext is created >+ * by the Web Services Explorer and passed to the transport stack during message creation. >+ * Implementers of ISOAPMessage should store a reference to the MessageContext. >+ * >+ * @return The MessageContext encasulating information about the web service operation. >+ * @see ISOAPTransport#newMessage(MessageContext) >+ */ >+ public MessageContext getMessageContext(); >+ >+ /** >+ * Sets a property in this ISOAPMessage. >+ * >+ * @param key The key (name) of the property >+ * @param value The value of the property. >+ */ >+ public void setProperty(String key, Object value); >+ >+ /** >+ * Retrieves a property from this ISOAPMessage. >+ * >+ * @param key The key (name) of the property to retrieve. >+ * @return The value assoicated with the given key, or null if there's no such property. >+ */ >+ public Object getProperty(String key); >+ >+ /** >+ * The namespace table holds the namespace declaraions that are on the envelope element >+ * of the SOAP message. The table's keys are the namespace URIs and the values are the >+ * associated namespace prefixes. >+ * <br/> >+ * <br/> >+ * The effect of calling this method is that the declarations in the namespace table >+ * argument should add to or replace the declarations on the envelope. This API does >+ * not specify what happens to existing declarations on the envelope which are not >+ * in the namespace table passed in. >+ * >+ * @param namespaceTable The namespace table >+ */ >+ public void setNamespaceTable(Map namespaceTable); >+ >+ /** >+ * Returns a table of the namespace declarations that are on the envelope element of the >+ * SOAP message. The table's keys are the namespace URIs and the values are the >+ * associated namespace prefixes. >+ * <br/> >+ * <br/> >+ * The namespace table returned by this method may be modified by the Web Services >+ * Explorer and later updated back to the message via the setNamesapceTable() method. >+ * >+ * @return A table of namespace URIs to prefixes on the SOAP envelope. >+ */ >+ public Map getNamespaceTable(); >+ >+ /** >+ * Sets the envelope element of this message. >+ * >+ * @param envelope The envelope element. >+ */ >+ public void setEnvelope(Element envelope); >+ >+ /** >+ * Returns the envelope element of this message. The deep parameter dictates whether >+ * the method returns the whole envelope with all its descendants or just the envelope >+ * element itself. >+ * >+ * @param deep If true, the envelope and its descendants are returned, otherwise only >+ * the envelope element itself is returned. >+ * @return An element. >+ */ >+ public Element getEnvelope(boolean deep); >+ >+ /** >+ * Sets the header element of this message. >+ * >+ * @param header The header element. >+ */ >+ public void setHeader(Element header); >+ >+ /** >+ * Returns the header element of this message. The deep parameter dictates whether >+ * the method returns the whole header with all its descendants or just the header >+ * element itself. >+ * >+ * @param deep If true, the header and its descendants are returned, otherwise only >+ * the header element itself is returned. >+ * @return An element. >+ */ >+ public Element getHeader(boolean deep); >+ >+ /** >+ * Sets an array of elements that goes into the message's header. >+ * >+ * @param headerContent An array of elements. >+ */ >+ public void setHeaderContent(Element[] headerContent); >+ >+ /** >+ * Returns the array of elements that are inside the message's header. >+ * >+ * @return An array of elements. >+ */ >+ public Element[] getHeaderContent(); >+ >+ /** >+ * Sets the body element of this message. For an RPC style message, the first child >+ * element of the body should be the RPC wrapper element. >+ * >+ * @param body The body element. >+ */ >+ public void setBody(Element body); >+ >+ /** >+ * Returns the body of this message. The deep parameter dictates whether >+ * the method returns the whole body with all its descendants elements or just the >+ * body. For an RPC style message, the first child element of the >+ * body should be the RPC wrapper element, regardless of the value of the deep >+ * parameter. >+ * >+ * @param deep If true, the body and its descendants are returned, otherwise only >+ * the body (and the RPC wrapper element if the message is RPC style) is returned. >+ * @return An element. >+ */ >+ public Element getBody(boolean deep); >+ >+ /** >+ * Sets an array of elements that goes into the message's body. For an RPC style >+ * message, the body contents are the elements inside the RPC wrapper element. >+ * >+ * @param bodyContent An array of elements. >+ */ >+ public void setBodyContent(Element[] bodyContent); >+ >+ /** >+ * Returns the array of elements that are inside the message's body. For an RPC style >+ * message, the body contents are the elements inside the RPC wrapper element. >+ * >+ * @return An array of elements. >+ */ >+ public Element[] getBodyContent(); >+ >+ /** >+ * Set the fault element for this message, if any. >+ * >+ * @param fault A fault element. >+ */ >+ public void setFault(Element fault); >+ >+ /** >+ * Returns the fault element, if any. >+ * >+ * @return The fault element or null if no fault has occurred. >+ */ >+ public Element getFault(); >+ >+ /** >+ * Returns the XML serialized form of this ISOAPMessage. >+ * >+ * @return An XML string. >+ * @see ISerializer >+ * @throws TransportException >+ */ >+ public String toXML() throws TransportException; >+ >+} >Index: src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransport.java >=================================================================== >RCS file: src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransport.java >diff -N src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransport.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransport.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.transport; >+ >+/** >+ * The ISOAPTransport is the core piece of the Web Services Explorer transport stack. >+ * It is responsible for invoking the web service and it also acts as the factory for >+ * creating ISerialier, IDeserializer, and ISOAPMessage instances which make up the >+ * rest of the WSE transport. >+ */ >+public interface ISOAPTransport { >+ >+ /** >+ * Factory method for ISerializer. >+ * >+ * @return An instance of ISerializer. >+ */ >+ public ISerializer newSerializer(); >+ >+ /** >+ * Factory method for IDeserializer. >+ * >+ * @return An instance of IDeserializer. >+ */ >+ public IDeserializer newDeserializer(); >+ >+ /** >+ * Factory method for ISOAPMessage. >+ * >+ * @param context MessageContext encapsulating information about the web service operation. >+ * @return An instance of ISOAPMessage. >+ * @throws TransportException >+ */ >+ public ISOAPMessage newMessage(MessageContext context) throws TransportException; >+ >+ /** >+ * Invokes the web service operation by sending the SOAP message, then parsing the results >+ * into a response ISOAPMessage. >+ * >+ * @param url The endpoint URL. >+ * @param username Username to use for basic auth protected endpoints. Set to null if not required. >+ * @param password Password to use for basic auth protected endpoints. Set to null if not required. >+ * @param message The SOAP request message. >+ * @return An ISOAPMesage representing the response from the web service invocation. >+ * @throws TransportException >+ */ >+ public ISOAPMessage send(String url, String username, String password, ISOAPMessage message) throws TransportException; >+} >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/TransportProviderRegistry.java >=================================================================== >RCS file: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/TransportProviderRegistry.java >diff -N wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/TransportProviderRegistry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/TransportProviderRegistry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,183 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.platform.perspective; >+ >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.Hashtable; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Preferences; >+import org.eclipse.wst.ws.internal.explorer.plugin.ExplorerPlugin; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransportProvider; >+ >+/** >+ * This class is responsible for loading the Web Services Explorer's transport provider >+ * extensions and instantiating them when needed. >+ */ >+public class TransportProviderRegistry { >+ >+ private static final String PREF_TRANSPORT_PROVIDERS = "TRANSPORT_PROVIDERS"; >+ private static final String EXTENSION_NAME = "wseTransportProvider"; >+ private static final String SOAP_TRANSPORT_PROVIDER = "soapTransportProvider"; >+ private static final String NAMESPACE_URI = "namespaceURI"; >+ private static final String TRANSPORT_URI = "transportURI"; >+ >+ private static TransportProviderRegistry instance = null; >+ >+ private List preferredIDs = null; >+ private Map soapProviderElements = null; >+ private Map soapProviderCache = null; >+ >+ /** >+ * Returns a singleton instance of this TransportProviderRegistry. >+ * >+ * @return An instance of this class. >+ */ >+ public synchronized static TransportProviderRegistry getInstance() { >+ if (instance == null) >+ instance = new TransportProviderRegistry(); >+ return instance; >+ } >+ >+ /* >+ * Constructor. >+ */ >+ private TransportProviderRegistry() { >+ >+ // get the preference value >+ Preferences preferences = ExplorerPlugin.getInstance().getPluginPreferences(); >+ String transportProviders = preferences.getString(PREF_TRANSPORT_PROVIDERS).replaceAll("\\s", ""); >+ >+ // split it into a list of preferred transport provider IDs >+ if (transportProviders.length() == 0) >+ preferredIDs = new ArrayList(); >+ else >+ preferredIDs = Arrays.asList(transportProviders.split(",")); >+ >+ // now find all extenders >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ IConfigurationElement[] configs = >+ registry.getConfigurationElementsFor(ExplorerPlugin.ID, EXTENSION_NAME); >+ >+ // currently we only have one type of providers: SOAP transport providers >+ soapProviderElements = new Hashtable(); >+ for (int i = 0; i < configs.length; i++) { >+ if (SOAP_TRANSPORT_PROVIDER.equals(configs[i].getName())) { >+ String id = configs[i].getAttribute("id"); >+ soapProviderElements.put(id, configs[i]); >+ } >+ } >+ >+ soapProviderCache = new Hashtable(); >+ } >+ >+ /* >+ * Determine if the URIs match. >+ */ >+ private boolean uriMatch(String required, String supported) { >+ >+ // not specified mean support everything >+ if (supported == null) >+ return true; >+ >+ if (!required.endsWith("/")) required += "/"; >+ if (!supported.endsWith("/")) supported += "/"; >+ >+ return required.equals(supported); >+ } >+ >+ /* >+ * Create the extension for the given key, but only if it supports the binding namespace and transport >+ */ >+ private ISOAPTransportProvider createExtension(Object key, String namespaceURI, String transportURI) { >+ >+ IConfigurationElement element = (IConfigurationElement) soapProviderElements.get(key); >+ if (element == null) >+ return null; >+ >+ boolean supportsNamespace = uriMatch(namespaceURI, element.getAttribute(NAMESPACE_URI)); >+ boolean supportsTransport = uriMatch(transportURI, element.getAttribute(TRANSPORT_URI)); >+ >+ if (supportsNamespace && supportsTransport) { >+ >+ String providerClassID = element.getAttribute("class"); >+ Object obj = null; >+ >+ try { >+ // check if we already have the transport provider cached, >+ // if not, then create one >+ synchronized (soapProviderCache) { >+ obj = soapProviderCache.get(providerClassID); >+ if (obj == null) { >+ obj = element.createExecutableExtension("class"); >+ soapProviderCache.put(providerClassID, obj); >+ } >+ } >+ return (ISOAPTransportProvider) obj; >+ } >+ catch (CoreException e) {} >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Get an ISOAPTransportProvider that supports the binding namespace and transport. This method will >+ * first look for preferred IDs defined using the TRANSPORT_PROVIDERS preference key. If a suitable >+ * provider is not found, it will then look at all other extenders in non-deterministic order. >+ * >+ * @param namespaceURI The binding namespace URI >+ * @param transportURI The binding transport URI >+ * >+ * @return Returns a suitable ISOAPTranportProvider for the given binding information, or null >+ * if there's no match. >+ */ >+ public ISOAPTransportProvider getSOAPTransportProvider(String namespaceURI, String transportURI) { >+ >+ ISOAPTransportProvider provider = null; >+ >+ Iterator iter = preferredIDs.iterator(); >+ >+ // check preferred IDs first >+ while (iter.hasNext()) { >+ provider = createExtension(iter.next(), namespaceURI, transportURI); >+ if (provider != null) >+ return provider; >+ } >+ >+ iter = soapProviderElements.keySet().iterator(); >+ >+ // check rest of the providers >+ while (iter.hasNext()) { >+ Object key = iter.next(); >+ >+ // already checked the preferred IDs >+ if (preferredIDs.contains(key)) >+ continue; >+ >+ provider = createExtension(key, namespaceURI, transportURI); >+ if (provider != null) >+ return provider; >+ } >+ >+ return null; >+ } >+} >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPMessageProcessor.java >=================================================================== >RCS file: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPMessageProcessor.java >diff -N wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPMessageProcessor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPMessageProcessor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,492 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; >+ >+import java.io.IOException; >+import java.util.Hashtable; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+import java.util.Vector; >+ >+import javax.wsdl.Operation; >+import javax.wsdl.Part; >+import javax.wsdl.extensions.ExtensibilityElement; >+import javax.wsdl.extensions.soap.SOAPBody; >+import javax.xml.parsers.ParserConfigurationException; >+ >+import org.apache.axis.Constants; >+import org.eclipse.wst.ws.internal.explorer.platform.util.XMLUtils; >+import org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.SoapHelper; >+import org.eclipse.wst.ws.internal.explorer.transport.IDeserializer; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage; >+import org.eclipse.wst.ws.internal.explorer.transport.ISerializer; >+import org.eclipse.wst.ws.internal.explorer.transport.MessageContext; >+import org.eclipse.wst.ws.internal.explorer.transport.TransportException; >+import org.w3c.dom.Attr; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+import org.w3c.dom.NamedNodeMap; >+import org.w3c.dom.Node; >+import org.w3c.dom.NodeList; >+import org.xml.sax.SAXException; >+ >+/** >+ * This class provides implementation for WSE default SOAP transport's ISerializer and IDeserializer. >+ */ >+public class SOAPMessageProcessor implements ISerializer, IDeserializer { >+ >+ private static final String LITERAL = "literal"; >+ private static final String DEFAULT_SOAP_ENCODING = "UTF-8"; >+ private static final String LINE_SEPARATOR = System.getProperties().getProperty("line.separator"); >+ >+ /* >+ * Join the encodingStyles into a space separated string >+ */ >+ private String joinEncodingStyles(List list) { >+ >+ if (list.isEmpty()) >+ return null; >+ >+ StringBuffer sb = new StringBuffer(); >+ >+ Iterator iter = list.iterator(); >+ while (iter.hasNext()) >+ sb.append(" ").append(iter.next()); >+ >+ return sb.substring(1).toString(); >+ } >+ >+ /* >+ * Retrieves the encoding information from the binding for the selected operation. >+ * This method is called only for RPC style bindings. Two pieces of information are returned: >+ * If the use is encoded, this method returns the encoding namespace in element [0] and the >+ * encoding style(s) in element [1]. If the use is literal, then both values will be null. >+ */ >+ private String[] getEncodingInfo(MessageContext context) { >+ >+ String[] info = new String[] { null, null }; >+ >+ Iterator iter = context.getBindingOperation().getBindingInput() >+ .getExtensibilityElements().iterator(); >+ >+ // look for the soapbind:body extensilibity element >+ while (iter.hasNext()) { >+ ExtensibilityElement e = (ExtensibilityElement) iter.next(); >+ if (!(e instanceof SOAPBody)) >+ continue; >+ >+ SOAPBody soapBody = (SOAPBody) e; >+ >+ // use="encoded" >+ if (!LITERAL.equals(soapBody.getUse())) { >+ info[0] = soapBody.getNamespaceURI(); >+ info[1] = joinEncodingStyles(soapBody.getEncodingStyles()); >+ } >+ >+ break; >+ } >+ >+ // namespace not specified on the soapbind:body element, use the definition's >+ if (info[0] == null) >+ info[0] = context.getDefinition().getTargetNamespace(); >+ >+ return info; >+ } >+ >+ /* >+ * WS-I: In a rpc-literal SOAP binding, the serialized child element of the >+ * soap:Body element consists of a wrapper element, whose namespace is the value >+ * of the namespace attribute of the soapbind:body element and whose local name is >+ * either the name of the operation or the name of the operation suffixed >+ * with "Response". The namespace attribute is required, as opposed to being >+ * optional, to ensure that the children of the soap:Body element are namespace- >+ * qualified. >+ */ >+ private Element createRPCWrapper(Document document, MessageContext context, Hashtable namespaceTable) { >+ >+ String encodingNamespaceURI = getEncodingInfo(context)[0]; >+ >+ return SoapHelper.createRPCWrapperElement( >+ document, >+ namespaceTable, >+ encodingNamespaceURI, >+ context.getBindingOperation().getOperation().getName(), >+ null); >+ } >+ >+ /* >+ * Initializes the contents of new ISOAPMessage. >+ */ >+ void initMessage(ISOAPMessage message) throws TransportException { >+ >+ try { >+ Document document = XMLUtils.createNewDocument(null); >+ >+ Hashtable namespaceTable = new Hashtable(); >+ SoapHelper.addDefaultSoapEnvelopeNamespaces(namespaceTable); >+ >+ message.setEnvelope(SoapHelper.createSoapEnvelopeElement(document, namespaceTable)); >+ message.setHeader(SoapHelper.createSoapHeaderElement(document)); >+ >+ Element body = SoapHelper.createSoapBodyElement(document); >+ if (!message.getMessageContext().isDocumentStyle()) { >+ Element rpcWrapper = createRPCWrapper(document, message.getMessageContext(), namespaceTable); >+ body.appendChild(rpcWrapper); >+ } >+ message.setBody(body); >+ >+ message.setNamespaceTable(namespaceTable); >+ } >+ catch (ParserConfigurationException e) { >+ throw new TransportException(e); >+ } >+ } >+ >+ /* >+ * Returns the first element with the given local name from the soap envelope namespace >+ * This method can be used on elements that are not namespace aware, but we have to give >+ * it a namespace table to look up prefixes. >+ */ >+ private Element getSOAPElement(Element root, String localName, Map namespaceTable) { >+ String prefix = (String) namespaceTable.get(Constants.URI_SOAP11_ENV); >+ if (prefix == null) >+ return null; >+ >+ NodeList list = root.getElementsByTagName(prefix + ":" + localName); >+ if (list.getLength() == 0) >+ return null; >+ >+ return (Element) list.item(0); >+ } >+ >+ /* >+ * Returns the first element with the given local name from the soap envelope namespace. >+ * This version assume the elements are namespace aware. >+ */ >+ private Element getSOAPElementNS(Element root, String localName) { >+ NodeList list = root.getElementsByTagNameNS(Constants.URI_SOAP11_ENV, localName); >+ if (list.getLength() == 0) >+ return null; >+ >+ return (Element) list.item(0); >+ } >+ >+ /* >+ * Convert a NodeList to a vector of elements, nodes which are not elements are skipped. >+ */ >+ private Vector toElementVector(NodeList nodes) { >+ >+ Vector vector = new Vector(); >+ >+ for (int i = 0; i < nodes.getLength(); i++) { >+ Node node = nodes.item(i); >+ if (node instanceof Element) >+ vector.add(node); >+ } >+ >+ return vector; >+ } >+ >+ /* >+ * Convert a NodeList to an array of elements, nodes which are not elements are skipped. >+ */ >+ private Element[] toElementArray(NodeList nodes) { >+ Vector vector = toElementVector(nodes); >+ Element[] elements = new Element[vector.size()]; >+ vector.copyInto(elements); >+ return elements; >+ } >+ >+ // Serialize //////////////////////////////////////////////////////////////////////////////////////////////////////////// >+ >+ /* >+ * adds the encoding style attribute to the each element in the given array. >+ * noop if encodingStyle is null >+ */ >+ private void addEncodingStyle(Element[] elements, String encodingStyle) { >+ >+ // encodingStyle is non-null only if use="encoded" >+ if (elements == null || encodingStyle == null) >+ return; >+ >+ for (int i=0; i < elements.length; i++) { >+ if (elements[i] == null) >+ continue; >+ elements[i].setAttribute( >+ Constants.NS_PREFIX_SOAP_ENV + ":" + Constants.ATTR_ENCODING_STYLE, encodingStyle); >+ } >+ } >+ >+ /* >+ * Serialize an array of elements >+ */ >+ private String serializeElements(Element[] elements) { >+ >+ StringBuffer buffer = new StringBuffer(); >+ >+ for (int i = 0; i < elements.length; i++) { >+ >+ String serializedFragment = XMLUtils.serialize(elements[i], true); >+ if (serializedFragment == null) { >+ // On Some JRE's (Sun java 5) elements with an attribute with the xsi >+ // prefix do not serialize properly because the namespace can not >+ // be found so the string returned comes back as null. To workaround >+ // this problem try adding in the namespace declaration attribute >+ // and retry the serialization (bug 144824) >+ elements[i].setAttribute("xmlns:xsi", Constants.URI_2001_SCHEMA_XSI); >+ serializedFragment = XMLUtils.serialize(elements[i], true); >+ } >+ >+ buffer.append(serializedFragment); >+ buffer.append(LINE_SEPARATOR); >+ } >+ >+ return buffer.toString(); >+ } >+ >+ /* >+ * Determines if the given message is a request message using RPC style >+ */ >+ private boolean isRPCRequest(ISOAPMessage message) { >+ return >+ !message.getMessageContext().isDocumentStyle() && // rpc style >+ !Boolean.TRUE.equals(message.getProperty(SOAPTransport.PROP_READ_ONLY)); // not read-only >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISerializer#serialize(int, org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage) >+ */ >+ public String serialize(int part, ISOAPMessage message) throws TransportException { >+ >+ switch (part) { >+ case ISOAPMessage.ENVELOPE: >+ Element envelope = message.getEnvelope(true); >+ >+ if (isRPCRequest(message)) { >+ Element body = getSOAPElementNS(envelope, Constants.ELEM_BODY); >+ if (body == null) >+ body = getSOAPElement(envelope, Constants.ELEM_BODY, message.getNamespaceTable()); >+ >+ if (body != null) { >+ Element[] bodyContent = toElementArray(body.getFirstChild().getChildNodes()); >+ addEncodingStyle(bodyContent, getEncodingInfo(message.getMessageContext())[1]); >+ } >+ } >+ >+ String xml = XMLUtils.serialize(envelope, true); >+ if (xml == null) >+ xml = new String((byte[]) message.getProperty(SOAPTransport.PROP_RAW_BYTES)); >+ >+ return xml; >+ >+ case ISOAPMessage.HEADER_CONTENT: >+ return serializeElements(message.getHeaderContent()); >+ >+ case ISOAPMessage.BODY_CONTENT: >+ Element[] bodyContent = message.getBodyContent(); >+ >+ if (isRPCRequest(message)) >+ addEncodingStyle(bodyContent, getEncodingInfo(message.getMessageContext())[1]); >+ >+ return serializeElements(bodyContent); >+ } >+ >+ return ""; >+ } >+ >+ // Deserialize ////////////////////////////////////////////////////////////////////////////////////////////////////////// >+ >+ /* >+ * Retrieve the soap header from the envelope and populate the given message >+ */ >+ private void processHeader(Element envelope, ISOAPMessage message) { >+ >+ Element header = getSOAPElementNS(envelope, Constants.ELEM_HEADER); >+ if (header == null) >+ return; >+ >+ message.setHeader(header); >+ message.setHeaderContent(toElementArray(header.getChildNodes())); >+ } >+ >+ /* >+ * HACK - The root element tag name of the instance document >+ * is ambiguous. It lands on a very grey area between the SOAP >+ * spec and the WSDL spec. The two specs do not explicitly define >+ * that the root element tag name must match the name of the >+ * WSDL part. The hack is to treat elements with different tag names >+ * as instances of the WSDL part. >+ */ >+ private Element[] fixSOAPResponse(NodeList instanceList, MessageContext context) { >+ >+ Vector instanceVector = toElementVector(instanceList); >+ Element[] instanceDocuments = new Element[instanceVector.size()]; >+ >+ Operation oper = context.getBindingOperation().getOperation(); >+ Map partsMap = oper.getOutput().getMessage().getParts(); >+ >+ if (partsMap.size() == 1) { >+ Iterator it = partsMap.values().iterator(); >+ Part part = (Part) it.next(); >+ >+ String fragName; >+ if (part.getElementName() != null) >+ fragName = part.getElementName().getLocalPart(); >+ else >+ fragName = part.getName(); >+ >+ for (int i = 0; i < instanceVector.size(); i++) { >+ Element element = (Element) instanceVector.get(i); >+ >+ if (!element.getTagName().equals(fragName)) { >+ Document doc = element.getOwnerDocument(); >+ NodeList children = element.getChildNodes(); >+ NamedNodeMap attributes = element.getAttributes(); >+ element = doc.createElement(fragName); >+ >+ for (int j = 0; j < children.getLength(); j++) { >+ if (children.item(j) != null) { >+ element.appendChild(children.item(j)); >+ // When you append a node from one element to another, >+ // the original element will lose its reference to this node, >+ // therefore, the size of the node list will decrease by 1. >+ j--; >+ } >+ } >+ >+ for (int j = 0; j < attributes.getLength(); j++) { >+ Object attr = attributes.item(j); >+ if (attr != null && (attr instanceof Attr)) { >+ Attr attribute = (Attr)attr; >+ element.setAttribute(attribute.getName(), attribute.getValue()); >+ } >+ } >+ } >+ instanceDocuments[i] = element; >+ } >+ } >+ else >+ instanceVector.copyInto(instanceDocuments); >+ >+ return instanceDocuments; >+ } >+ >+ /* >+ * Retrieve the soap header from the envelope and populate the given message >+ */ >+ private void processBody(Element envelope, ISOAPMessage message) { >+ >+ Element body = getSOAPElementNS(envelope, Constants.ELEM_BODY); >+ if (body == null) >+ return; >+ >+ message.setBody(body); >+ >+ // check for soap fault >+ Element fault = getSOAPElementNS(body, Constants.ELEM_FAULT); >+ if (fault != null) { >+ message.setFault(fault); >+ return; >+ } >+ >+ NodeList instanceList; >+ >+ if (message.getMessageContext().isDocumentStyle()) >+ instanceList = body.getChildNodes(); >+ else { >+ NodeList rpcWrapper = body.getElementsByTagNameNS("*", >+ message.getMessageContext().getBindingOperation().getOperation().getOutput().getMessage().getQName().getLocalPart()); >+ >+ /* >+ * HACK - Some of the web services out on the internet do not >+ * set their RPC wrapper properly. It should be set to the output >+ * message name of the selected operation. The hack is to >+ * assume the first element inside the body element is the >+ * RPC wrapper. >+ */ >+ if (rpcWrapper.getLength() <= 0) >+ rpcWrapper = body.getElementsByTagNameNS("*", "*"); >+ >+ if (rpcWrapper.getLength() > 0) >+ instanceList = rpcWrapper.item(0).getChildNodes(); >+ else >+ return; >+ } >+ >+ message.setBodyContent(fixSOAPResponse(instanceList, message.getMessageContext())); >+ } >+ >+ /* >+ * Deserialize the byte array into the given soap message. The part parameters tells >+ * the method whether the input is the whole envelop or just the contents of the >+ * header or body. >+ */ >+ void deserialize(int part, byte[] xml, ISOAPMessage message) throws >+ ParserConfigurationException, >+ SAXException, >+ IOException { >+ >+ Element root = XMLUtils.byteArrayToElement(xml, true); >+ >+ switch (part) { >+ case ISOAPMessage.ENVELOPE: >+ message.setEnvelope(root); >+ processHeader(root, message); >+ processBody(root, message); >+ break; >+ case ISOAPMessage.HEADER_CONTENT: >+ message.setHeaderContent(toElementArray(root.getChildNodes())); >+ break; >+ case ISOAPMessage.BODY_CONTENT: >+ message.setBodyContent(toElementArray(root.getChildNodes())); >+ break; >+ } >+ } >+ >+ /* >+ * Tack on a root element the string which represents a series of elements. >+ * This is needed to deserialize the string. >+ */ >+ private String addRootElement(String xml, Map namespaceTable) { >+ StringBuffer sb = new StringBuffer(); >+ sb.append("<root"); >+ >+ Iterator iter = namespaceTable.keySet().iterator(); >+ while (iter.hasNext()) { >+ Object uri = iter.next(); >+ Object prefix = namespaceTable.get(uri); >+ sb.append(" ").append("xmlns:").append(prefix).append("=\"").append(uri).append("\""); >+ } >+ >+ sb.append(">").append(xml).append("</root>"); >+ return sb.toString(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.IDeserializer#deserialize(int, java.lang.String, org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage) >+ */ >+ public void deserialize(int part, String xml, ISOAPMessage message) throws TransportException { >+ >+ if (part != ISOAPMessage.ENVELOPE) >+ xml = addRootElement(xml, message.getNamespaceTable()); >+ >+ try { >+ deserialize(part, xml.getBytes(DEFAULT_SOAP_ENCODING), message); >+ } >+ catch (Exception e) { >+ throw new TransportException(e); >+ } >+ } >+} >Index: schema/wseTransportProvider.exsd >=================================================================== >RCS file: schema/wseTransportProvider.exsd >diff -N schema/wseTransportProvider.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/wseTransportProvider.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,145 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.wst.ws.explorer"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.wst.ws.explorer" id="wseTransportProvider" name="Web Services Explorer Transport Provider"/> >+ </appInfo> >+ <documentation> >+ [Enter description of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <complexType> >+ <sequence minOccurs="1" maxOccurs="unbounded"> >+ <element ref="soapTransportProvider"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ A fully qualified identifier of the target extension point >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ An optional identifier for this extension instance >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ An optional name this extension instance >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="soapTransportProvider"> >+ <annotation> >+ <documentation> >+ This extension point entry allows an extender to plug in a new factory for creating org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransport instances. The ISOAPTranport is used by the Web Services Explorer for invoking web services operations that uses the SOAP message protocol. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ This class must implement the org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransportProvider interface. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransportProvider"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ This id uniquely identifies this soapTransportProvider element. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The name of this soapTransportProvider element. >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ <attribute name="namespaceURI" type="string"> >+ <annotation> >+ <documentation> >+ The namespace URI of the soap:binding element that this transport provider claims support for. For example, if this transport provider supports the SOAP 1.1 binding, the value of this attribute would be http://schemas.xmlsoap.org/wsdl/soap/. If unspecified, this transport provider claims support for all SOAP bindings. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="transportURI" type="string"> >+ <annotation> >+ <documentation> >+ The transport protocol URI of the soap:binding element that this transport provider claims support for. For example, if this transport provider supports SOAP over HTTP, the value of this attribute would be http://schemas.xmlsoap.org/soap/http. If unspecified, this transport provider claims support for all transport protocols. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ <b>This extension point is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.</b> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ [Enter extension point usage example here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ Copyright (c) 2007 IBM Corporation and others.<br> >+All rights reserved. This program and the accompanying materials are made >+available under the terms of the Eclipse Public License v1.0 which accompanies >+this distribution, and is available at <a >+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPTransport.java >=================================================================== >RCS file: wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPTransport.java >diff -N wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPTransport.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/SOAPTransport.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,148 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; >+ >+import javax.wsdl.extensions.ExtensibilityElement; >+import javax.wsdl.extensions.soap.SOAPBinding; >+ >+import org.apache.axis.Constants; >+import org.eclipse.wst.ws.internal.explorer.platform.perspective.MessageProvider; >+import org.eclipse.wst.ws.internal.explorer.transport.IDeserializer; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage; >+import org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransport; >+import org.eclipse.wst.ws.internal.explorer.transport.ISerializer; >+import org.eclipse.wst.ws.internal.explorer.transport.MessageContext; >+import org.eclipse.wst.ws.internal.explorer.transport.SOAPMessage; >+import org.eclipse.wst.ws.internal.explorer.transport.TransportException; >+import org.eclipse.wst.ws.internal.parser.discovery.NetUtils; >+ >+/** >+ * WSE's default implementation of ISOAPTransport >+ */ >+public class SOAPTransport extends MessageProvider implements ISOAPTransport { >+ >+ static final String PROP_READ_ONLY = "prop_read_only"; >+ static final String PROP_RAW_BYTES = "prop_raw_bytes"; >+ >+ /* >+ * Contructor. >+ */ >+ SOAPTransport() { >+ super("wsdl"); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransport#newSerializer() >+ */ >+ public ISerializer newSerializer() { >+ return new SOAPMessageProcessor(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransport#newDeserializer() >+ */ >+ public IDeserializer newDeserializer() { >+ return new SOAPMessageProcessor(); >+ } >+ >+ /* >+ * Check if the binding is supported >+ */ >+ private void checkBinding(ExtensibilityElement binding) throws TransportException { >+ >+ String bindingURI = binding.getElementType().getNamespaceURI(); >+ >+ // looking for SOAP 1.1 binding >+ if (!(binding instanceof SOAPBinding) || >+ !Constants.URI_WSDL11_SOAP.equals(bindingURI)) >+ throw new TransportException(getMessage("MSG_ERROR_UNSUPPORTED_BINDING", bindingURI)); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransport#newMessage(org.eclipse.wst.ws.internal.explorer.transport.MessageContext) >+ */ >+ public ISOAPMessage newMessage(MessageContext context) throws TransportException { >+ >+ checkBinding(context.getBindingProtocol()); >+ >+ SOAPMessageProcessor processor = new SOAPMessageProcessor(); >+ ISOAPMessage message = new SOAPMessage(context, processor); >+ processor.initMessage(message); >+ return message; >+ } >+ >+ /* >+ * Check if the message uses a binding and transport that we support. >+ */ >+ private void checkMessage(ISOAPMessage message) throws TransportException { >+ >+ ExtensibilityElement binding = message.getMessageContext().getBindingProtocol(); >+ checkBinding(binding); >+ >+ SOAPBinding soapBinding = (SOAPBinding) binding; >+ >+ if (!Constants.URI_SOAP11_HTTP.equals(soapBinding.getTransportURI())) >+ throw new TransportException(getMessage("MSG_ERROR_UNSUPPORTED_TRANSPORT", soapBinding.getTransportURI())); >+ } >+ >+ /* >+ * Create an HTTPTransport for internal use. >+ */ >+ private HTTPTransport createInternalTransport(String username, String password) { >+ >+ HTTPTransport internalTransport = new HTTPTransport(); >+ >+ if (username != null && password != null) { >+ internalTransport.setHttpBasicAuthUsername(username); >+ internalTransport.setHttpBasicAuthPassword(password); >+ } >+ >+ return internalTransport; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPTransport#send(java.lang.String, java.lang.String, java.lang.String, org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage) >+ */ >+ public ISOAPMessage send(String url, String username, String password, ISOAPMessage message) throws TransportException { >+ >+ checkMessage(message); >+ >+ try { >+ HTTPTransport internalTransport = createInternalTransport(username, password); >+ internalTransport.send(NetUtils.createURL(url), (String) message.getProperty(ISOAPMessage.PROP_SOAP_ACTION), message.toXML()); >+ >+ SOAPMessageProcessor processor = new SOAPMessageProcessor(); >+ ISOAPMessage reply = new SOAPMessage(message.getMessageContext(), processor); >+ reply.setProperty(PROP_READ_ONLY, Boolean.TRUE); >+ >+ byte[] rawBytes = internalTransport.receiveBytes(); >+ >+ try { >+ processor.deserialize(ISOAPMessage.ENVELOPE, rawBytes, reply); >+ } >+ catch (Exception e) { >+ // if error occurs during deserialization, we want to save a copy of the actual raw bytes >+ reply.setProperty(PROP_RAW_BYTES, rawBytes); >+ } >+ >+ return reply; >+ } >+ catch (TransportException e) { >+ throw e; >+ } >+ catch (Exception e) { >+ throw new TransportException(e); >+ } >+ } >+} >Index: src/org/eclipse/wst/ws/internal/explorer/transport/ISerializer.java >=================================================================== >RCS file: src/org/eclipse/wst/ws/internal/explorer/transport/ISerializer.java >diff -N src/org/eclipse/wst/ws/internal/explorer/transport/ISerializer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/ws/internal/explorer/transport/ISerializer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.transport; >+ >+/** >+ * The ISerializer is responsible for taking an ISOAPMessage and serializing it >+ * into an XML string. >+ */ >+public interface ISerializer { >+ >+ /** >+ * Serialize the ISOAPMessage into an XML string. The part parameter tells the method >+ * which part of the message (the envelope or the contents of the header or body) to >+ * serialize. Note that "contents" refers to the list of elements inside the header >+ * or body, and not the header or body element itself. >+ * >+ * @param part One of {@link ISOAPMessage#ENVELOPE}, {@link ISOAPMessage#HEADER_CONTENT}, or >+ * {@link ISOAPMessage#BODY_CONTENT}. >+ * @param message The ISOAPMessage to serialize. >+ * @return An XML string. >+ * @throws TransportException >+ */ >+ public String serialize(int part, ISOAPMessage message) throws TransportException; >+} >Index: src/org/eclipse/wst/ws/internal/explorer/transport/IDeserializer.java >=================================================================== >RCS file: src/org/eclipse/wst/ws/internal/explorer/transport/IDeserializer.java >diff -N src/org/eclipse/wst/ws/internal/explorer/transport/IDeserializer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/ws/internal/explorer/transport/IDeserializer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.transport; >+ >+/** >+ * The IDeserializer is responsible for taking an XML string and deserializing it >+ * into values to populate an ISOAPMessage. >+ */ >+public interface IDeserializer { >+ >+ /** >+ * Deserialize the XML string into the ISOAPMessage. The part parameter tells the method >+ * which part of the message (the envelope or the contents of the header or body) the XML >+ * string represents. Note that "contents" refers to the list of elements inside the header >+ * or body, and not the header or body element itself. >+ * >+ * @param part One of {@link ISOAPMessage#ENVELOPE}, {@link ISOAPMessage#HEADER_CONTENT}, or >+ * {@link ISOAPMessage#BODY_CONTENT}. >+ * @param xml The XML string to deserialize. >+ * @param message The ISOAPMessage to deserialize into. >+ * @throws TransportException >+ */ >+ public void deserialize(int part, String xml, ISOAPMessage message) throws TransportException; >+} >Index: src/org/eclipse/wst/ws/internal/explorer/transport/SOAPMessage.java >=================================================================== >RCS file: src/org/eclipse/wst/ws/internal/explorer/transport/SOAPMessage.java >diff -N src/org/eclipse/wst/ws/internal/explorer/transport/SOAPMessage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/ws/internal/explorer/transport/SOAPMessage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,339 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable >+ *******************************************************************************/ >+package org.eclipse.wst.ws.internal.explorer.transport; >+ >+import java.util.Hashtable; >+import java.util.Iterator; >+import java.util.Map; >+ >+import org.w3c.dom.Attr; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+import org.w3c.dom.NamedNodeMap; >+import org.w3c.dom.Node; >+import org.w3c.dom.NodeList; >+ >+/** >+ * This is a default implementation of the ISOAPMessage interface that extenders of the Web >+ * Services Explorer transport can use if they do not wish to implement their own message. >+ * This class is implemented as a collection of loose pieces of the SOAP message, and each >+ * piece must be set individually (for example, setting the envelope element will not >+ * automatically populate the header or body elements). >+ * <br/> >+ * <br/> >+ * This class does not know how to serialize itself. It depends on an ISerializer provided by >+ * the transport extender. >+ */ >+public final class SOAPMessage implements ISOAPMessage { >+ >+ private MessageContext context; >+ private ISerializer serializer; >+ >+ private Map properties = new Hashtable(); >+ >+ private Element envelope = null; >+ >+ private Element header = null; >+ private Element[] headerContent = null; >+ >+ private Element body = null; >+ private Element[] bodyContent = null; >+ >+ private Element fault = null; >+ >+ private String xml = null; >+ >+ /** >+ * Constructor. >+ * >+ * @param context The MessageContext. >+ * @param serializer An ISerializer to use to serialize this message. >+ */ >+ public SOAPMessage(MessageContext context, ISerializer serializer) { >+ this.context = context; >+ this.serializer = serializer; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getMessageContext() >+ */ >+ public MessageContext getMessageContext() { >+ return context; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setProperty(java.lang.String, java.lang.Object) >+ */ >+ public void setProperty(String key, Object value) { >+ properties.put(key, value); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getProperty(java.lang.String) >+ */ >+ public Object getProperty(String key) { >+ return properties.get(key); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setNamespaceTable(java.util.Map) >+ */ >+ public synchronized void setNamespaceTable(Map namespaceTable) { >+ if (namespaceTable == null || envelope == null) >+ return; >+ >+ Iterator iter = namespaceTable.entrySet().iterator(); >+ >+ while (iter.hasNext()) { >+ Map.Entry entry = (Map.Entry) iter.next(); >+ String name = "xmlns:" + entry.getValue(); >+ envelope.setAttribute(name, entry.getKey().toString()); >+ } >+ >+ xml = null; >+ } >+ >+ /* >+ * If the attribute is a namespace declaration, the namespace prefix is returned. >+ * Otherwise null is returned. >+ */ >+ private String getNSPrefix(Attr attribute) { >+ String name = attribute.getName(); >+ if (name.startsWith("xmlns:")) >+ return name.substring(6); >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getNamespaceTable() >+ */ >+ public Map getNamespaceTable() { >+ >+ Hashtable namespaceTable = new Hashtable(); >+ >+ if (envelope != null) { >+ NamedNodeMap attributes = envelope.getAttributes(); >+ for (int i = 0; i < attributes.getLength(); i++) { >+ Attr attribute = (Attr) attributes.item(i); >+ String prefix = getNSPrefix(attribute); >+ if (prefix != null) >+ namespaceTable.put(attribute.getValue(), prefix); >+ } >+ } >+ >+ return namespaceTable; >+ } >+ >+ /* >+ * Appends a child node to a parent node, takes care of importing >+ * the child node if neccessary. >+ */ >+ private void appendNode(Node parent, Node child) { >+ if (parent == null || child == null) >+ return; >+ >+ Document owner = parent.getOwnerDocument(); >+ >+ if (!owner.equals(child.getOwnerDocument())) >+ child = owner.importNode(child, true); >+ >+ parent.appendChild(child); >+ } >+ >+ /* >+ * Adds an array of elements to the parent element as child elements. >+ */ >+ private void appendChildren(Element parent, Element[] children) { >+ if (parent == null || children == null) >+ return; >+ >+ for (int i = 0; i < children.length; i++) { >+ if (children[i] == null) >+ continue; >+ appendNode(parent, children[i]); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setEnvelope(org.w3c.dom.Element) >+ */ >+ public synchronized void setEnvelope(Element envelope) { >+ if (envelope == null) >+ this.envelope = envelope; >+ else >+ this.envelope = (Element) envelope.cloneNode(false); >+ >+ xml = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getEnvelope(boolean) >+ */ >+ public Element getEnvelope(boolean deep) { >+ if (!deep) >+ return envelope; >+ >+ synchronized (this) { >+ if (envelope == null) >+ return null; >+ >+ Element clonedEnvelope = (Element) envelope.cloneNode(false); >+ >+ if (headerContent != null && headerContent.length > 0) >+ appendNode(clonedEnvelope, getHeader(true)); >+ >+ appendNode(clonedEnvelope, getBody(true)); >+ >+ return clonedEnvelope; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setHeader(org.w3c.dom.Element) >+ */ >+ public synchronized void setHeader(Element header) { >+ if (header == null) >+ this.header = null; >+ else >+ this.header = (Element) header.cloneNode(false); >+ >+ xml = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getHeader(boolean) >+ */ >+ public Element getHeader(boolean deep) { >+ if (!deep) >+ return header; >+ >+ synchronized (this) { >+ if (header == null) >+ return null; >+ >+ Element clonedHeader = (Element) header.cloneNode(false); >+ appendChildren(clonedHeader, headerContent); >+ return clonedHeader; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setHeaderContent(org.w3c.dom.Element[]) >+ */ >+ public synchronized void setHeaderContent(Element[] headerContent) { >+ this.headerContent = headerContent; >+ xml = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getHeaderContent() >+ */ >+ public Element[] getHeaderContent() { >+ return headerContent; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setBody(org.w3c.dom.Element) >+ */ >+ public synchronized void setBody(Element body) { >+ if (body == null) >+ this.body = null; >+ else { >+ this.body = (Element) body.cloneNode(false); >+ >+ if (!context.isDocumentStyle() && fault == null) { >+ NodeList childElements = body.getElementsByTagName("*"); >+ if (childElements.getLength() > 0) >+ this.body.appendChild(childElements.item(0).cloneNode(false)); >+ } >+ } >+ xml = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getBody(boolean) >+ */ >+ public Element getBody(boolean deep) { >+ if (!deep) >+ return body; >+ >+ synchronized (this) { >+ if (body == null) >+ return null; >+ >+ // copy the rpc wrapper element as well, if any >+ Element clonedBody = (Element) body.cloneNode(true); >+ >+ if (fault != null) >+ appendNode(clonedBody, fault); >+ else { >+ Element target = clonedBody; >+ >+ // check for rpc wrapper >+ if (clonedBody.getFirstChild() != null) >+ target = (Element) clonedBody.getFirstChild(); >+ >+ appendChildren(target, bodyContent); >+ } >+ >+ return clonedBody; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setBodyContent(org.w3c.dom.Element[]) >+ */ >+ public synchronized void setBodyContent(Element[] bodyContent) { >+ this.bodyContent = bodyContent; >+ if (bodyContent != null) >+ fault = null; >+ xml = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getBodyContent() >+ */ >+ public Element[] getBodyContent() { >+ return bodyContent; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setFault(org.w3c.dom.Element) >+ */ >+ public synchronized void setFault(Element fault) { >+ this.fault = fault; >+ if (fault != null) { >+ if (body != null && body.getFirstChild() != null) >+ body.removeChild(body.getFirstChild()); >+ bodyContent = null; >+ } >+ xml = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getFault() >+ */ >+ public Element getFault() { >+ return fault; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#toXML() >+ */ >+ public synchronized String toXML() throws TransportException { >+ if (xml == null) >+ xml = serializer.serialize(ENVELOPE, this); >+ return xml; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 176493
:
64218
|
66381