aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.ws.wsdl; aoqi@0: aoqi@0: import com.sun.istack.internal.NotNull; aoqi@0: import com.sun.istack.internal.Nullable; aoqi@0: import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; aoqi@0: import com.sun.xml.internal.ws.api.model.SEIModel; aoqi@0: import com.sun.xml.internal.ws.api.model.WSDLOperationMapping; aoqi@0: import com.sun.xml.internal.ws.api.WSBinding; aoqi@0: import com.sun.xml.internal.ws.api.message.Packet; aoqi@0: import com.sun.xml.internal.ws.api.message.Message; aoqi@0: import com.sun.xml.internal.ws.resources.ServerMessages; aoqi@0: import com.sun.xml.internal.ws.fault.SOAPFaultBuilder; aoqi@0: aoqi@0: import javax.xml.namespace.QName; aoqi@0: import java.util.List; aoqi@0: import java.util.ArrayList; aoqi@0: import java.text.MessageFormat; aoqi@0: aoqi@0: /** aoqi@0: * This class abstracts the process of identifying the wsdl operation from a SOAP Message request. aoqi@0: * This is primarily for dispatching the request messages to an endpoint method. aoqi@0: * aoqi@0: * Different implementations of {@link WSDLOperationFinder} are used underneath to identify the wsdl operation based on aoqi@0: * if AddressingFeature is enabled or not. aoqi@0: * aoqi@0: * @author Rama Pulavarthi aoqi@0: */ aoqi@0: public class OperationDispatcher { aoqi@0: private List opFinders; aoqi@0: private WSBinding binding; aoqi@0: aoqi@0: public OperationDispatcher(@NotNull WSDLPort wsdlModel, @NotNull WSBinding binding, @Nullable SEIModel seiModel) { aoqi@0: this.binding = binding; aoqi@0: opFinders = new ArrayList(); aoqi@0: if (binding.getAddressingVersion() != null) { aoqi@0: opFinders.add(new ActionBasedOperationFinder(wsdlModel, binding, seiModel)); aoqi@0: } aoqi@0: opFinders.add(new PayloadQNameBasedOperationFinder(wsdlModel, binding, seiModel)); aoqi@0: opFinders.add(new SOAPActionBasedOperationFinder(wsdlModel, binding, seiModel)); aoqi@0: aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * @deprecated use getWSDLOperationMapping(Packet request) aoqi@0: * @param request Packet aoqi@0: * @return QName of the wsdl operation. aoqi@0: * @throws DispatchException if a unique operartion cannot be associated with this packet. aoqi@0: */ aoqi@0: public @NotNull QName getWSDLOperationQName(Packet request) throws DispatchException { aoqi@0: WSDLOperationMapping m = getWSDLOperationMapping(request); aoqi@0: return m != null ? m.getOperationName() : null; aoqi@0: } aoqi@0: aoqi@0: public @NotNull WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException { aoqi@0: WSDLOperationMapping opName; aoqi@0: for(WSDLOperationFinder finder: opFinders) { aoqi@0: opName = finder.getWSDLOperationMapping(request); aoqi@0: if(opName != null) aoqi@0: return opName; aoqi@0: } aoqi@0: //No way to dispatch this request aoqi@0: String err = MessageFormat.format("Request=[SOAPAction={0},Payload='{'{1}'}'{2}]", aoqi@0: request.soapAction, request.getMessage().getPayloadNamespaceURI(), aoqi@0: request.getMessage().getPayloadLocalPart()); aoqi@0: String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(err); aoqi@0: Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage( aoqi@0: binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient); aoqi@0: throw new DispatchException(faultMsg); aoqi@0: } aoqi@0: }