2
* Copyright 2001-2004 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package samples.proxy;
19
import org.apache.axis.AxisFault;
20
import org.apache.axis.Handler;
21
import org.apache.axis.Message;
22
import org.apache.axis.MessageContext;
23
import org.apache.axis.SimpleTargetedChain;
24
import org.apache.axis.client.Call;
25
import org.apache.axis.client.Service;
26
import org.apache.axis.message.SOAPEnvelope;
27
import org.w3c.dom.Document;
28
import samples.transport.tcp.TCPSender;
29
import samples.transport.tcp.TCPTransport;
32
* Proxy sample. Relays message on to hardcoded URL.
33
* Soon, URL becomes configurable (via deployment?!);
34
* later, URL becomes specifiable in custom header.
36
* @author Rob Jellinghaus <robj@unrealities.com>
39
public class ProxyService {
41
* Process the given message, treating it as raw XML.
43
public void proxyService(SOAPEnvelope env1, SOAPEnvelope env2)
47
// Get the current Message Context
48
MessageContext msgContext = MessageContext.getCurrentContext();
50
// Look in the message context for our service
51
Handler self = msgContext.getService();
53
// what is our target URL?
54
String dest = (String)self.getOption("URL");
56
// use the server's client engine in case anything has
57
// been deployed to it
58
Service service = new Service();
59
service.setEngine( msgContext.getAxisEngine().getClientEngine() );
60
Call call = (Call) service.createCall();
62
SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
64
//service.getEngine().deployTransport("tcp", c);
66
// add TCP for proxy testing
67
call.addTransportPackage("samples.transport");
68
call.setTransportForProtocol("tcp", TCPTransport.class);
70
// NOW set the client's URL (since now the tcp handler exists)
71
call.setTargetEndpointAddress(new java.net.URL(dest));
73
call.setRequestMessage(msgContext.getRequestMessage());
77
Message msg = call.getResponseMessage();
79
msgContext.setResponseMessage(msg);
81
catch( Exception exp ) {
82
throw AxisFault.makeFault( exp );