You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2005/02/25 04:34:28 UTC

svn commit: r155296 - in incubator/beehive/trunk: samples/wsm-samples/ samples/wsm-samples/WEB-INF/src/web/header/ wsm/src/runtime/org/apache/beehive/wsm/wsdl/

Author: mmerz
Date: Thu Feb 24 19:34:25 2005
New Revision: 155296

URL: http://svn.apache.org/viewcvs?view=rev&rev=155296
Log:
Added sample for the headers.

Contributor: Daryoush Mehrtash

Added:
    incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/
    incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/ServiceSignHandler.java
    incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignException.java
    incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignHandler.java
    incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureTool.java
    incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureToolImpl.java
    incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuote.java
    incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuoteImpl.jws
Modified:
    incubator/beehive/trunk/samples/wsm-samples/index.html
    incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/WSDLParser.java

Added: incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/ServiceSignHandler.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/ServiceSignHandler.java?view=auto&rev=155296
==============================================================================
--- incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/ServiceSignHandler.java (added)
+++ incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/ServiceSignHandler.java Thu Feb 24 19:34:25 2005
@@ -0,0 +1,57 @@
+package web.header;
+
+/*
+ * Copyright 2004, 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+/*  
+ * Note:  This sample was developed based on the example in the article:
+ * http://www-128.ibm.com/developerworks/webservices/library/ws-tip-extend/
+ */
+
+import javax.xml.rpc.handler.MessageContext;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+
+/**
+ * Service-side SignHandler. Verify signature on incoming request messages, sign
+ * outgoing response messages,
+ */
+public class ServiceSignHandler extends SignHandler {
+    /**
+     * Check incoming request message.
+     */
+    public boolean handleRequest(MessageContext mc) {
+        checkIncoming((SOAPMessageContext) mc);
+        return true;
+    }
+
+    /**
+     * Sign outgoing request message.
+     */
+    public boolean handleResponse(MessageContext mc) {
+        signOutgoing((SOAPMessageContext) mc);
+        return true;
+    }
+
+    /**
+     * Sign outgoing request message.
+     */
+    public boolean handleFault(MessageContext mc) {
+        signOutgoing((SOAPMessageContext) mc);
+        return true;
+    }
+}

Added: incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignException.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignException.java?view=auto&rev=155296
==============================================================================
--- incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignException.java (added)
+++ incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignException.java Thu Feb 24 19:34:25 2005
@@ -0,0 +1,58 @@
+package web.header;
+
+/*
+ * Copyright 2004, 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+/*  
+ * Note:  This sample was developed based on the example in the article:
+ * http://www-128.ibm.com/developerworks/webservices/library/ws-tip-extend/
+ */
+/**
+ * SignException for general faults associated with signing.
+ */
+public class SignException extends RuntimeException {
+
+    /**
+     * 
+     */
+    public SignException() {
+        super();
+    }
+
+    /**
+     * @param message
+     */
+    public SignException(String message) {
+        super(message);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public SignException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * @param cause
+     */
+    public SignException(Throwable cause) {
+        super(cause);
+    }
+}

Added: incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignHandler.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignHandler.java?view=auto&rev=155296
==============================================================================
--- incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignHandler.java (added)
+++ incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignHandler.java Thu Feb 24 19:34:25 2005
@@ -0,0 +1,322 @@
+package web.header;
+/*
+ * Copyright 2004, 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+/*  
+ * Note:  This sample was developed based on the example in the article:
+ * http://www-128.ibm.com/developerworks/webservices/library/ws-tip-extend/
+ */
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.handler.Handler;
+import javax.xml.rpc.handler.HandlerInfo;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+
+
+/**
+ * Provides common behavior for client & service handlers,
+ * generalized as outgoing and incoming message processing.
+ */
+abstract class SignHandler implements Handler
+{
+    /**
+     * Header element namespace
+     */
+    private static final String SIGN_NS_URI
+        = "uri://org.example.webservices.signature.Sign";
+
+    /**
+     * Header element namespace prefix
+     */
+    private static final String SIGN_PREFIX
+        = "sign";
+
+    /**
+     * Header element
+     */
+    private static final String SIGN_ELEMENT
+        = "sign";
+
+    /**
+     * Header element qualifed name
+     */
+    private static final QName SIGN_HEADER
+        = new QName(SIGN_NS_URI, SIGN_ELEMENT);
+
+
+    private SignatureTool signatureTool
+        = new SignatureToolImpl();
+
+    private HandlerInfo info;
+
+
+    /**
+     * Name of required property, in HandlerInfo handler configuration,
+     * that specifies who signs outgoing messages.
+     */
+    public  static final String SIGNERS_NAME_PROPERTY
+        = "org.example.webservices.signature.SignersName";
+    
+    /**
+     * Set of SOAP headers that this handler knows how to process.
+     * It is expected that this is set on the HandlerInfo for
+     * instances of this handler's subclasses.
+     */
+    public  static final QName[] HEADERS
+        = new QName[] { SIGN_HEADER };
+
+
+    public void init(HandlerInfo config) {
+        info = config;
+    }
+
+    public void destroy() {}
+
+    public QName[] getHeaders() { return info.getHeaders(); }
+
+
+    /**
+     * Obtain signers name from handler configuration (HandlerInfo),
+     * and sign message.
+     * @throws SignException if SIGNERS_NAME_PROPERTY is not available
+     *                       in the handler config.
+     */
+    public void signOutgoing(SOAPMessageContext mc) throws SignException {
+        /**
+         * SIGNERS_NAME_PROPERTY is required to be on the configuration.
+         */
+        Map config = info.getHandlerConfig();
+        if (config == null) {
+            throw new SignException("Signers Name not provided");
+        }
+
+        Object nameObj = config.get(SIGNERS_NAME_PROPERTY);
+        if (!(nameObj instanceof String)) {
+            throw new SignException("Signers Name not provided");
+        }
+        
+        String name = (String)nameObj;
+        
+
+        try {
+            /**
+             * Dig down into message, locate or create header block.
+             */
+            SOAPMessage msg = mc.getMessage();
+            SOAPPart part = msg.getSOAPPart();
+            SOAPEnvelope envelope = part.getEnvelope();
+        
+            SOAPHeader header = envelope.getHeader();
+            if (header == null) {
+                header = envelope.addHeader();
+            }
+            
+            /**
+             * Create new header element.
+             * Use simple-security as role
+             */
+            SOAPHeaderElement headerElement
+                = (SOAPHeaderElement)header.addChildElement(SIGN_ELEMENT,
+                                                            SIGN_PREFIX,
+                                                            SIGN_NS_URI);
+            headerElement.setActor("simple-security");
+//  Just sign with name in the header, leave the content alone
+//            /**
+//             * Locate portion of message content that is to be signed.
+//             */
+//            SOAPElement content = getContent(part);
+
+            /**
+             * Create new element representing signature,
+             * and add as child to new header element.
+             */
+            SOAPElement element = signatureTool.getSignature(name);   //, content);
+            headerElement.addChildElement(element);
+        } catch (SOAPException e) {
+            e.printStackTrace();
+            throw new SignException("Unable to sign message", e);
+        }
+    }
+
+
+    /**
+     * Look for signature on incoming message.
+     * If signature not found, then continue message processing.
+     * If signature is found, then verify that it is "correct".
+     * If correct, then continue message processing.
+     * If not correct, then throw SignException.
+     */
+    public void checkIncoming(SOAPMessageContext mc) throws SignException {
+        int     validSignatures = 0;
+        boolean expectedSignature = false;
+
+        try {
+            SOAPMessage msg = mc.getMessage();
+            SOAPPart part = msg.getSOAPPart();
+            SOAPEnvelope envelope = part.getEnvelope();
+
+            
+//            /**
+//             * Locate portion of message content that is to be signed.
+//             */
+//            SOAPElement content = getContent(part);
+
+
+            /**
+             * Dig down through SOAP headers looking for matches to
+             * SIGN_HEADER, that are also targeted for this SOAP Node.
+             */
+            SOAPHeader header = envelope.getHeader();
+            if (header != null) {
+                /**
+                 * The roles the node acts in are specified by the
+                 * MessageContext.getRoles() method.  This code
+                 * examines each role independently.
+                 */
+                String[] roles = mc.getRoles();
+
+                /**
+                 * If no roles are found, then default to
+                 * "ultimate destination".
+                 */
+                if (roles == null  ||  roles.length == 0) {
+                    System.out.println("checkIncoming: no roles, " +
+                                       "default to ultimate destination");
+                    roles = new String[] { "" };
+                }
+
+                /**
+                 * Examine headers bound to each role this node acts in.
+                 */
+                for (int ridx = 0; ridx < roles.length; ridx++) {
+                    String role = roles[ridx];
+
+                    System.out.println("checkIncoming: role == \"" +
+                                       role + "\"");
+                    
+                    /**
+                     * Headers are determined to be targeted for a SOAP Node by
+                     * matching the node's roles with the header's actor role.
+                     *
+                     * So now go through list of headers associated with
+                     * the role we are currently working on.
+                     */
+                    Iterator headerElementIter
+                        = header.examineHeaderElements(role);
+    
+                    while (headerElementIter.hasNext()) {
+                        SOAPHeaderElement headerElement
+                            = (SOAPHeaderElement)headerElementIter.next();
+    
+                        /**
+                         * Is header recognized by this handler?
+                         */
+                        Name headerElementName
+                            = headerElement.getElementName();
+
+                        if (equals(headerElementName, SIGN_HEADER)) {
+                            System.out.println("checkIncoming: header match" +
+                                               ": \"" +
+                                               elementName(headerElementName) +
+                                               "\"");
+
+                            /**
+                             * We got this far, we expect a signature now.
+                             */
+                            expectedSignature = true;
+
+                            /**
+                             * Look for SOAPElement(s) in header,
+                             * ignoring mixed content.
+                             */
+                            Iterator headerIter
+                                = headerElement.getChildElements();
+    
+                            while (headerIter.hasNext()) {
+                                Object elementObj = headerIter.next();
+    
+                                if (elementObj instanceof SOAPElement) {
+                                    SOAPElement element
+                                        = (SOAPElement)elementObj;
+
+                                    signatureTool.isSignatureValid(element); //,content);
+                                    validSignatures++;
+                                }
+                            }
+                        }
+                    }
+                }
+            } else {
+                System.out.println("Header not found!");
+            }
+        } catch (SOAPException e) {
+            e.printStackTrace();
+            throw new SignException("Unable to verify signature", e);
+        }
+        
+        /**
+         * Throw an exception if we ever got to a point where we
+         * expected a signature, but then we never found one
+         * [this logic is weak, but sufficient].
+         */
+        if (expectedSignature && validSignatures < 1) {
+            throw new SignException("Expected signature(s) not found");
+        }
+    }
+    
+    /**
+     * Compare two qnames
+     */
+    private boolean equals(Name name, QName qname) {
+        return (name == null  &&  qname == null) ||
+               (name.getURI().equals(qname.getNamespaceURI()) &&
+                name.getLocalName().equals(qname.getLocalPart()));
+    }
+    
+//    /**
+//     * Helper method, return content of SOAPPart that we want to sign.
+//     */
+//    private SOAPElement getContent(SOAPPart part) throws SOAPException {
+//        SOAPEnvelope envelope = part.getEnvelope();
+//        return envelope.getBody();
+//    }
+
+    /**
+     * Return name of SOAPElement as a String.
+     */
+    private String elementName(SOAPElement e) {
+        return elementName(e.getElementName());
+    }
+    
+    /**
+     * Return name of SOAPElement as a String.
+     */
+    private String elementName(Name name) {
+        return "{" + name.getURI() + "}" + name.getLocalName();
+    }
+}

Added: incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureTool.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureTool.java?view=auto&rev=155296
==============================================================================
--- incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureTool.java (added)
+++ incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureTool.java Thu Feb 24 19:34:25 2005
@@ -0,0 +1,43 @@
+package web.header;
+/*
+ * Copyright 2004, 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+/*  
+ * Note:  This sample was developed based on the example in the article:
+ * http://www-128.ibm.com/developerworks/webservices/library/ws-tip-extend/
+ */
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+
+
+interface SignatureTool {
+    /**
+     * @return Result of signer signing content.
+     */
+    public SOAPElement getSignature(String signersName) //, SOAPElement content) 
+    throws SOAPException;
+
+
+    /**
+     * @return true if content was signed, unchanged, by signer of signature.
+     * This is only true if the content is the same content signed originally
+     * by a signer, resulting in signature.
+     */
+    public boolean isSignatureValid(SOAPElement signature) //, SOAPElement content) 
+    throws SOAPException;
+}

Added: incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureToolImpl.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureToolImpl.java?view=auto&rev=155296
==============================================================================
--- incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureToolImpl.java (added)
+++ incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/SignatureToolImpl.java Thu Feb 24 19:34:25 2005
@@ -0,0 +1,188 @@
+package web.header;
+/*
+ * Copyright 2004, 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+/*  
+ * Note:  This sample was developed based on the example in the article:
+ * http://www-128.ibm.com/developerworks/webservices/library/ws-tip-extend/
+ */
+import java.util.Iterator;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.Text;
+
+
+/**
+ * Produce signature of the form:
+ *   <simpleSignature>
+ *     <signer>...</signer>
+ *     <seal>...</seal>
+ *   </simpleSignature>
+ */
+public class SignatureToolImpl implements SignatureTool {
+    private static final SOAPFactory factory;
+
+    private static final String SIGNATURE_NS = "uri://org.example.webservices.signature.SimpleSignature";
+    private static final String SIGNATURE_NS_PREFIX = "ssig";
+
+    private static final String SIGNATURE_ELEMENT = "signature";
+    private static final String SIGNER_ELEMENT = "signer";
+    private static final String SEAL_ELEMENT = "seal";
+
+    private static final Name   SIGNATURE_NAME;
+    private static final Name   SIGNER_NAME;
+    private static final Name   SEAL_NAME;
+
+
+    static {
+        try {
+            factory = SOAPFactory.newInstance();
+            
+            SIGNATURE_NAME = factory.createName(SIGNATURE_ELEMENT,
+                                                SIGNATURE_NS_PREFIX,
+                                                SIGNATURE_NS);
+
+            SIGNER_NAME = factory.createName(SIGNER_ELEMENT);
+
+            SEAL_NAME = factory.createName(SEAL_ELEMENT);
+        } catch (SOAPException e) {
+            e.printStackTrace();
+            throw new SignException("SignatureToolImpl init failed", e);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.example.webservices.signature.SignatureTool#getSignature(java.lang.String, javax.xml.soap.SOAPElement)
+     */
+    public SOAPElement getSignature(String signersName) //, SOAPElement content)
+        throws SOAPException
+    {
+        SOAPElement sig = factory.createElement(SIGNATURE_NAME);
+
+        SOAPElement signer = sig.addChildElement(SIGNER_NAME);
+        signer.addTextNode(signersName);
+
+        SOAPElement seal = sig.addChildElement(SEAL_NAME);
+ //       String strContent = getContent(content);
+        String signature = sign(signersName);  //, strContent);
+        System.out.println("getSignature: seal= " + signature);
+
+        seal.addTextNode(signature);
+
+        return sig;
+    }
+
+    /* (non-Javadoc)
+     * @see org.example.webservices.signature.SignatureTool#isSignatureValid(javax.xml.soap.SOAPElement, javax.xml.soap.SOAPElement)
+     */
+    public boolean isSignatureValid(SOAPElement signature) //, SOAPElement content)
+        throws SOAPException
+    {
+        System.out.println("Testing signature");
+        if (!signature.getElementName().equals(SIGNATURE_NAME)) {
+            System.out.println("Failed signature test... SIGNATURE_NAME doesn't exist.");
+           throw new SignException("Unexpected element.  got \"" +
+                                    signature.getElementName() +
+                                    "\", expected \"" +
+                                    SIGNATURE_NAME + "\"");
+        }
+        
+        Iterator signerIter = signature.getChildElements(SIGNER_NAME);
+        if (!signerIter.hasNext()) {
+            System.out.println("Failed signature test... SIGNATURE_NAME doesn't have any child");
+           throw new SignException("Expected element missing.  expected \"" +
+                                    SIGNER_NAME + "\"");
+        }
+        SOAPElement signer = (SOAPElement)signerIter.next();
+        
+        Iterator sealIter = signature.getChildElements(SEAL_NAME);
+        if (!sealIter.hasNext()) {
+            System.out.println("Failed signature test... SIGNATURE_NAME doesn't have SEAL_NAME");
+             throw new SignException("Expected element missing.  expected \"" +
+                                    SEAL_NAME + "\"");
+        }
+        SOAPElement seal = (SOAPElement)sealIter.next();
+
+        String signersName = signer.getValue();
+ //       String strContent = getContent(content);
+        String signedContent = sign(signersName);  //, strContent);
+        
+        String sealedContent = seal.getValue();
+
+        System.out.println("isSignatureValid: expected= " + signedContent);
+        System.out.println("isSignatureValid: received= " + sealedContent);
+
+        if (!signedContent.equals(sealedContent)) {
+            System.out.println("Signatures don't match!");
+             throw new SignException("Signed document does not match signature");
+        }
+
+        System.out.println("signatures match!");
+        return true;
+    }
+    
+    /**
+     * So here we do a VERY simple (and unsecure) signature.
+     * There are texts on how to do a secure signature,
+     * but they are all beyond the scope of this handler sample.
+     * 
+     * @param signer
+     * @param root
+     * @return
+     */
+    protected String sign(String signer) {  //, String content) {
+        return signer; //+ "#" + content;
+    }
+
+
+    /**
+     * Reminder: this is not about performance, or security...
+     */
+    private String getContent(SOAPElement element) throws SOAPException {
+        String result = elementName(element) + "=(";
+
+        int count = 0;
+        Iterator children = element.getChildElements();
+        while (children.hasNext()) {
+            Object child = children.next();
+            if (child instanceof SOAPElement) {
+                result += getContent((SOAPElement)child);
+                if (count > 0) result += ",";
+                count++;
+            } else if (child instanceof Text) {
+                result += ((Text)child).getValue();
+                if (count > 0) result += ",";
+                count++;
+            }
+        }
+        result += ")";
+
+        return result;
+    }
+
+    private String elementName(SOAPElement e) {
+        return elementName(e.getElementName());
+    }
+    
+    private String elementName(Name name) {
+        return "{" + name.getURI() + "}" + name.getLocalName();
+    }
+}

Added: incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuote.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuote.java?view=auto&rev=155296
==============================================================================
--- incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuote.java (added)
+++ incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuote.java Thu Feb 24 19:34:25 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004, 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+/*  
+ * Note:  This sample was developed based on the example in the article:
+ * http://www-128.ibm.com/developerworks/webservices/library/ws-tip-extend/
+ */
+
+
+package web.header;
+
+public interface StockQuote  {
+    public float getQuote(java.lang.String arg0);
+}

Added: incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuoteImpl.jws
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuoteImpl.jws?view=auto&rev=155296
==============================================================================
--- incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuoteImpl.jws (added)
+++ incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/header/StockQuoteImpl.jws Thu Feb 24 19:34:25 2005
@@ -0,0 +1,68 @@
+package web.header;
+
+/*
+ * Copyright 2004, 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+/*  
+ * Note:  This sample was developed based on the example in the article:
+ * http://www-128.ibm.com/developerworks/webservices/library/ws-tip-extend/
+ */
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.InitParam;
+import javax.jws.soap.SOAPMessageHandler;
+import javax.jws.soap.SOAPMessageHandlers;
+
+
+/**
+ * Serve up stock quotes.
+ */
+@WebService(targetNamespace="http://beehive.apache.org/wsm/web/header_sample")
+@SOAPMessageHandlers({
+  @SOAPMessageHandler(
+    className = "web.header.ServiceSignHandler",
+    roles = {"simple-security"},
+        initParams = {
+      @InitParam(name=SignHandler.SIGNERS_NAME_PROPERTY
+      , value="beehive")
+      }
+  )
+})
+public class StockQuoteImpl implements StockQuote {
+
+    /**
+     * Return a "quote" (not-live) for stock symbol.
+     */
+    @WebMethod
+    public float getQuote(String symbol)  {
+        double quote = 0.0;
+        System.out.println("Get quote for" + symbol);
+
+        // Quote is function of the symbol characters
+        for (int i = 0; i < symbol.length(); i++) {
+            int c = symbol.charAt(i) & 0x1F;
+            int digit = c % 10;
+
+            quote = (quote * 10.0) + digit;
+        }
+
+        // One decimal place.
+        return (float)(quote / 10.0);
+    }
+}

Modified: incubator/beehive/trunk/samples/wsm-samples/index.html
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/index.html?view=diff&r1=155295&r2=155296
==============================================================================
--- incubator/beehive/trunk/samples/wsm-samples/index.html (original)
+++ incubator/beehive/trunk/samples/wsm-samples/index.html Thu Feb 24 19:34:25 2005
@@ -19,6 +19,12 @@
 status page, the likely cause is that you have multiple XML
 parsers in your classpath. Clean up your classpath by eliminating
 extraneous parsers.
+    <li>
+        View
+        <a href="web/header/StockQuoteImpl.jws?wsdl">WSDL</a>
+        for Header sample.<br />
+        
+    </li>
 </ul>
 </p>
 <hr>

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/WSDLParser.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/WSDLParser.java?view=diff&r1=155295&r2=155296
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/WSDLParser.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/WSDLParser.java Thu Feb 24 19:34:25 2005
@@ -35,7 +35,10 @@
 import org.w3.x2001.xmlSchema.TopLevelElement;
 import org.w3.x2001.xmlSchema.TopLevelSimpleType;
 import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
+import org.xmlsoap.schemas.wsdl.TPort;
+import org.xmlsoap.schemas.wsdl.TService;
 import org.xmlsoap.schemas.wsdl.TTypes;
+import org.xmlsoap.schemas.wsdl.soap.TAddress;
 
 public class WSDLParser {
 
@@ -65,6 +68,25 @@
      */
     public Schema getSchema() {
         return schema;
+    }
+    
+    public String getSoapAddressLocation() throws IllegalAccessException {
+        String location = null;
+         TService[] services = defDoc.getDefinitions().getServiceArray();
+        if (services.length > 0) {
+            TPort port = services[0].getPortArray(0);
+            if(null != port) {
+                 try {
+                    TAddress[] soapAddress = Utilities.selectChildren(port, TAddress.class);
+                    if(soapAddress.length > 0) {
+                        location = soapAddress[0].getLocation();
+                    }
+                } catch (NoSuchFieldException e) {
+                    // just return null 
+                }
+            }
+        }
+         return location;
     }
 
 }