001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.axis2.description;
021:
022: import org.apache.axiom.om.util.UUIDGenerator;
023: import org.apache.axiom.soap.SOAPEnvelope;
024: import org.apache.axis2.AxisFault;
025: import org.apache.axis2.client.OperationClient;
026: import org.apache.axis2.client.Options;
027: import org.apache.axis2.context.MessageContext;
028: import org.apache.axis2.context.ServiceContext;
029: import org.apache.axis2.engine.AxisEngine;
030: import org.apache.axis2.transport.TransportUtils;
031: import org.apache.axis2.util.Utils;
032:
033: import javax.xml.namespace.QName;
034: import java.io.InputStream;
035:
036: public class RobustOutOnlyAxisOperation extends OutInAxisOperation {
037:
038: public RobustOutOnlyAxisOperation() {
039: super ();
040: //setup a temporary name
041: QName tmpName = new QName(this .getClass().getName() + "_"
042: + UUIDGenerator.getUUID());
043: this .setName(tmpName);
044: setMessageExchangePattern(WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY);
045: }
046:
047: public RobustOutOnlyAxisOperation(QName name) {
048: super (name);
049: setMessageExchangePattern(WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY);
050: }
051:
052: public OperationClient createClient(ServiceContext sc,
053: Options options) {
054: return new RobustOutOnlyOperationClient(this , sc, options);
055: }
056:
057: class RobustOutOnlyOperationClient extends OutInAxisOperationClient {
058:
059: public RobustOutOnlyOperationClient(OutInAxisOperation axisOp,
060: ServiceContext sc, Options options) {
061: super (axisOp, sc, options);
062: }
063:
064: protected void timeOut() throws AxisFault {
065: //Nothing to worry
066: }
067:
068: /**
069: * If there is a fault then need to handle that
070: * @param responseMessageContext responseMessageContext
071: * @throws AxisFault
072: */
073: protected void handleResponse(
074: MessageContext responseMessageContext) throws AxisFault {
075: SOAPEnvelope envelope = responseMessageContext
076: .getEnvelope();
077: if (envelope == null) {
078: // If request is REST we assume the responseMessageContext is REST, so
079: // set the variable
080: InputStream inStream = (InputStream) responseMessageContext
081: .getProperty(MessageContext.TRANSPORT_IN);
082: if (inStream != null) {
083: envelope = TransportUtils
084: .createSOAPMessage(responseMessageContext);
085: responseMessageContext.setEnvelope(envelope);
086: }
087: responseMessageContext.setEnvelope(envelope);
088: }
089: if (envelope != null) {
090: if (envelope.getBody().hasFault()
091: || responseMessageContext.isProcessingFault()) {
092: //receiving a fault
093: AxisEngine.receive(responseMessageContext);
094: throw Utils
095: .getInboundFaultFromMessageContext(responseMessageContext);
096: }
097: }
098: }
099: }
100: }
|