3e114360bf1a6d7cf1b32349e41b84ac524547d5
[shibboleth/cpp-xmltooling.git] / xmltooling / soap / SOAPClient.h
1 /*
2  *  Copyright 2001-2006 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file xmltooling/soap/SOAPClient.h
19  * 
20  * Implements SOAP 1.1 messaging over a transport.
21  */
22
23 #ifndef __xmltooling_soap11client_h__
24 #define __xmltooling_soap11client_h__
25
26 #include <xmltooling/soap/SOAP.h>
27 #include <xmltooling/soap/SOAPTransport.h>
28
29 namespace soap11 {
30     
31     /**
32      * Implements SOAP 1.1 messaging over a transport.
33      * 
34      * In the abstract, this can be a one-way exchange, or use asynchronous
35      * transports, but this is mostly theoretical.
36      */
37     class XMLTOOL_API SOAPClient
38     {
39         MAKE_NONCOPYABLE(SOAPClient);
40     public:
41         SOAPClient() : m_response(NULL) {}
42         virtual ~SOAPClient();
43         
44         /**
45          * Sends the supplied envelope to the identified recipient/endpoint.
46          * 
47          * <p>The caller is responsible for freeing the outgoing envelope.
48          * 
49          * <p>The client object will instantiate a transport layer object
50          * appropriate for the endpoint URL provided and supply it to the
51          * prepareTransport() method below.
52          * 
53          * @param env       SOAP envelope to send
54          * @param to        identifier/name of party to send message to
55          * @param endpoint  URL of endpoint to recieve message
56          */
57         virtual void send(const Envelope* env, const char* to, const char* endpoint);
58         
59         /**
60          * Returns the response message, if any. As long as a response is
61          * "expected" but not available, NULL will be returned. If no response
62          * will be forthcoming, an exception is raised.
63          * 
64          * <p>The caller is responsible for freeing the incoming envelope.
65          */
66         virtual Envelope* receive();
67
68     protected:
69         /**
70          * Allows client to supply transport-layer settings prior to sending message.
71          * 
72          * @param transport reference to transport layer
73          * @return true iff transport preparation was successful 
74          */
75         virtual bool prepareTransport(const xmltooling::SOAPTransport& transport) {}
76         
77         /** Holds response until retrieved by caller. */
78         Envelope* m_response;
79     };
80
81 };
82
83 #endif /* __xmltooling_soap11client_h__ */