// SrmWsClient.cxx #include "dataset_util/Text.h" #include #include "dial_ws_srm/SrmWsClient.h" extern SOAP_NMAC struct Namespace dial_ws_srm_namespaces[]; using std::string; using std::ostream; using std::endl; using std::vector; using dial::SrmWsClient; typedef SrmWsClient::Name Name; typedef SrmWsClient::NameList NameList; typedef SrmWsClient::RequestStatus RequestStatus; typedef vector NamePtrList; //********************************************************************** // Local definitions. //********************************************************************** namespace { } // end unnamed namespace //********************************************************************** // Constructors and destructor. //********************************************************************** // Constructor. SrmWsClient::SrmWsClient(string url, bool usegsi) : WsClient(url, usegsi) { psoap()->namespaces = dial_ws_srm_namespaces; } //********************************************************************** // Methods. //********************************************************************** // Validity. bool SrmWsClient::is_valid() const { return ping(); } //********************************************************************** // Ping. bool SrmWsClient::ping() const { //2.7.0f ns1__pingResponse res; //res.pingReturn = false; bool res = false; int sstat = soap_call_ns5__ping(psoap(), curl(), "", res); if ( sstat != SOAP_OK ) { soap_print_fault(psoap(), stderr); return false; } //2.7.0f return res.pingReturn; return res; } //********************************************************************** // Protocols. NameList SrmWsClient::protocols() const { NameList names; ns5__getProtocolsResponse res; int sstat = soap_call_ns5__getProtocols(psoap(), curl(), "", res); if ( sstat != SOAP_OK ) { soap_print_fault(psoap(), stderr); return names; } int count = res.getProtocolsReturn->__size; string* pname = *res.getProtocolsReturn->__ptr; assert( pname != 0 ); for ( int icnt=0; icnt(surl_ptrs.front()); surlbox.__size = int(surl_ptrs.size()); surlbox.soap = 0; // Create struct to hold protocols for service call. ArrayOf_USCORExsd_USCOREstring protbox; protbox.__ptr = &const_cast(prot_ptrs.front()); protbox.__size = int(prot_ptrs.size()); protbox.soap = 0; // Output results. ns5__getResponse rqstbox; //ns3__RequestStatus* prqstbox = 0; // Call service. std::cout << ">>> " << surlbox.__size << std::endl; std::cout << ">>> " << *surlbox.__ptr << std::endl; std::cout << ">>> " << protbox.__size << std::endl; std::cout << ">>> " << *protbox.__ptr << std::endl; int sstat = soap_call_ns5__get( psoap(), curl(), "", &surlbox, &protbox, rqstbox ); if ( sstat != SOAP_OK ) { soap_print_fault(psoap(), stderr); return RequestStatus(); } ns4__RequestStatus* pgrs = rqstbox._getReturn; assert( pgrs != 0 ); RequestStatus rstat(*pgrs); assert( rstat.file_statuses().size() == surls.size() ); return rstat; } //********************************************************************** // Free functions. //********************************************************************** // Output stream. ostream& operator<<(ostream& lhs, const dial::SrmWsClient& rhs) { bool ok = rhs.ping(); NameList prots ; const char* curl = rhs.curl(); if ( ok ) prots = rhs.protocols(); NameList::size_type nprot = prots.size(); lhs.flush(); lhs << "SRM client is "; if ( ok ) { lhs << "connected to"; } else { lhs << "is unable to ping"; } if ( curl ) { lhs << " the service at" << endl; lhs << " " << rhs.curl(); } if ( ok ) { lhs << "\n Service has " << nprot << " transfer protocol"; if ( nprot != 1 ) lhs << "s"; if ( nprot != 0 ) lhs << ":"; for ( NameList::const_iterator ipro=prots.begin(); ipro!=prots.end(); ++ipro ) { lhs << " " << *ipro; } } return lhs; } //**********************************************************************