Package org.apache.muse.ws.metadata.remote

Source Code of org.apache.muse.ws.metadata.remote.MetadataExchangeClient

/*=============================================================================*
*  Copyright 2006 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.
*=============================================================================*/

package org.apache.muse.ws.metadata.remote;

import org.w3c.dom.Element;

import org.apache.muse.core.AbstractResourceClient;
import org.apache.muse.core.Environment;
import org.apache.muse.util.xml.XmlUtils;
import org.apache.muse.ws.addressing.EndpointReference;
import org.apache.muse.ws.addressing.soap.SoapClient;
import org.apache.muse.ws.addressing.soap.SoapFault;
import org.apache.muse.ws.metadata.WsxConstants;
import org.apache.muse.ws.metadata.impl.GetMetadataRequest;

/**
*
* MetadataExchangeClient is a client for invoking the web services operations
* in WS-MetadataExchange 09/2004. It also have a convenience method, getWSDL(),
* that allows users to get the WSDL document for a resource without calling
* getMetadata() and parsing the results.
*
* @author Dan Jemiolo (danj)
*
*/

public class MetadataExchangeClient extends AbstractResourceClient
{
    public MetadataExchangeClient(EndpointReference destination)
    {
        super(destination);
    }

    public MetadataExchangeClient(EndpointReference destination,
                                  EndpointReference source)
    {
        super(destination, source);
    }

    public MetadataExchangeClient(EndpointReference destination,
                                  EndpointReference source,
                                  Environment environment)
    {
        super(destination, source, environment);
    }

    public MetadataExchangeClient(EndpointReference destination,
                                  EndpointReference source,
                                  SoapClient soapClient)
    {
        super(destination, source, soapClient);
    }
   
    public Element[] getMetadata(String dialect)
        throws SoapFault
    {
        GetMetadataRequest get = new GetMetadataRequest(dialect);
       
        Element response = invoke(WsxConstants.GET_METADATA_URI, get.toXML());
       
        //
        // each child element is a MetadataSection - we want to dig down
        // one level deeper and get the actual content for the user
        //
        Element[] sections = XmlUtils.getAllElements(response);
        Element[] metadata = new Element[sections.length];
       
        for (int n = 0; n < sections.length; ++n)
            metadata[n] = XmlUtils.getFirstElement(sections[n]);
       
        return metadata;
    }
   
    /**
     *
     * This is a convenience method that calls getMetadata(String) with the
     * WSDL dialect.
     *
     * @return The WSDL document for the resource, or null if the dialect
     *         is not supported.
     *
     */
    public Element getWSDL()
        throws SoapFault
    {
        Element[] response = getMetadata(WsxConstants.WSDL_DIALECT);
        return response.length == 0 ? null : response[0];
    }
}
TOP

Related Classes of org.apache.muse.ws.metadata.remote.MetadataExchangeClient

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.