Пример #1
0
SOAP_FMAC1
void
SOAP_FMAC2
soap_print_fault(struct soap *soap, std::ostream& msg)
{ if (soap->error)
  { if (!*soap_faultcode(soap))
      soap_set_fault(soap);
    if (!*soap_faultstring(soap))
      *soap_faultstring(soap) = "";
    msg << "SOAP FAULT: "
        << *soap_faultcode(soap) << std::endl
        << "\"" << *soap_faultstring(soap) << "\"" << std::endl;
    if (*soap_faultdetail(soap))
      msg << "Detail: " << *soap_faultdetail(soap) << std::endl;
  }
}
Пример #2
0
    void UserGetProfiles(struct soap *soap, struct _tds__GetCapabilitiesResponse *capa_resp)  
    {  
	struct _trt__GetProfiles trt__GetProfiles;
        struct _trt__GetProfilesResponse trt__GetProfilesResponse;
        int result= SOAP_OK ;  
        printf("\n-------------------Getting Onvif Devices Profiles--------------\n\n");  
        soap_wsse_add_UsernameTokenDigest(soap,"user", ONVIF_USER, ONVIF_PASSWORD);  


        result = soap_call___trt__GetProfiles(soap, capa_resp->Capabilities->Media->XAddr, NULL, &trt__GetProfiles, &trt__GetProfilesResponse);  
        if (result==-1)  
        //NOTE: it may be regular if result isn't SOAP_OK.Because some attributes aren't supported by server.  
        {  
          	 printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));  
           	 result = soap->error;  
           	 exit(-1);  
        }  
        else{  
       		 printf("\n-------------------Profiles Get OK--------------\n\n");  
         	 if(trt__GetProfilesResponse.Profiles!=NULL)  
         	 {  
			int profile_cnt = trt__GetProfilesResponse.__sizeProfiles;
			printf("the number of profiles are: %d\n", profile_cnt);
           	     if(trt__GetProfilesResponse.Profiles->Name!=NULL) 
           	         printf("Profiles Name:%s  \n",trt__GetProfilesResponse.Profiles->Name);  

            	     if(trt__GetProfilesResponse.Profiles->token!=NULL) 
             	       printf("Profiles Taken:%s\n",trt__GetProfilesResponse.Profiles->token);  
		     UserGetUri(soap, &trt__GetProfilesResponse, capa_resp);
           	 }  
           	 else
            	    printf("Profiles Get inner Error\n");  
        } 
        printf("Profiles Get Procedure over\n");  
    }  
Пример #3
0
int ns3__getQuote(struct soap *soap, char *symbol, char *country, float &result)
{ float q, r;
  // soap->user contains an environment that we can use to make calls that do not interfere with the current service environment
  if (soap_call_ns1__getQuote((struct soap*)soap->user, "http://services.xmethods.net/soap", NULL, symbol, q) == 0 &&
      soap_call_ns2__getRate((struct soap*)soap->user, "http://services.xmethods.net/soap", NULL, "us", country, r) == 0)
  { result = q*r;
    return SOAP_OK;
  }
  soap_receiver_fault(soap, *soap_faultstring((struct soap*)soap->user), NULL);
  return SOAP_FAULT;	// pass soap fault messages on to the client of this app
}
Пример #4
0
static void _fault_to_error(glite_delegation_ctx *ctx, const char *method)
{
    const char **code, **string, **detail;
    struct soap *soap = ctx->soap;

    soap_set_fault(soap);

    if (soap->fault)
    {
        /* Look for a SOAP 1.1 fault */
        if (soap->fault->detail)
            decode_exception(ctx, soap->fault->detail, method);
        /* Look for a SOAP 1.2 fault */
        if (soap->fault->SOAP_ENV__Detail)
            decode_exception(ctx, soap->fault->SOAP_ENV__Detail, method);
    }

    /* If we did not manage to decode the exception, try generic error
    * decoding */
    if (!ctx->error)
    {
        code = soap_faultcode(soap);
        string = soap_faultstring(soap);
        detail = soap_faultdetail(soap);

        /* If the SOAP 1.1 detail is empty, try the SOAP 1.2 detail */
        if (!detail && soap->fault && soap->fault->SOAP_ENV__Detail)
            detail = (const char **)&soap->fault->SOAP_ENV__Detail->__any;

        /* Provide default messages */
        if (!code || !*code)
        {
            code = alloca(sizeof(*code));
            *code = "(SOAP fault code missing)";
        }
        if (!string || !*string)
        {
            string = alloca(sizeof(*string));
            *string = "(SOAP fault string missing)";
        }

        if (detail && *detail)
            glite_delegation_set_error(ctx, "%s: SOAP fault: %s - %s (%s)", method, *code,
                *string, *detail);
        else
            glite_delegation_set_error(ctx, "%s: SOAP fault: %s - %s", method, *code,
                *string);
    }

    soap_end(soap);
}
Пример #5
0
/*
 * This method is used to print the SOAP fault to a string
 */
void soap_sprint_fault(struct soap *soap, char *fd)
{ if (soap->error)
  { const char *c, *v = NULL, *s, **d;
    d = soap_faultcode(soap);
    if (!*d)
      soap_set_fault(soap);
    c = *d;
    if (soap->version == 2)
      v = *soap_faultsubcode(soap);
    s = *soap_faultstring(soap);
    d = soap_faultdetail(soap);
    sprintf(fd, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c, v ? v : "no subcode", s ? s : "[no reason]", d && *d ? *d : "[no detail]");
  }
}
Пример #6
0
static int my_soap_set_error(struct soap *soap, const char *faultcode,
		const char *faultsubcodeQName, const char *faultstring,
		const char *faultdetailXML, int soaperror) {
	*soap_faultcode(soap) = faultcode;
	if (faultsubcodeQName)
		*soap_faultsubcode(soap) = faultsubcodeQName;
	*soap_faultstring(soap) = faultstring;
	if (faultdetailXML && *faultdetailXML) {
		register const char **s = soap_faultdetail(soap);
		if (s)
			*s = faultdetailXML;
	}
	return soap->error = soaperror;
}
Пример #7
0
	void Request::Execute()
	    {
	    try
		{
		this->setEndpoint();

		this->setHeader();

		try
		    {
		    this->getRequest();

		    }
		catch (soap* soap)
		    {

		    if (soap_check_state(soap))
			std::clog
				<< "Error: soap struct state not initialized\n";
		    else if (soap->error)
			{
			const char *c, *v = NULL, *s, **d;
			d = soap_faultcode(soap);
			if (!*d)
			    soap_set_fault(soap);
			c = *d;
			if (soap->version == 2)
			    v = *soap_faultsubcode(soap);
			s = *soap_faultstring(soap);
			d = soap_faultdetail(soap);
			std::clog << (soap->version ? "SOAP 1." : "Error ")
				<< (soap->version ? (int) soap->version
					: soap->error) << " fault: " << c
				<< "[" << (v ? v : "no subcode") << "]"
				<< std::endl << "\"" << (s ? s : "[no reason]")
				<< "\"" << std::endl << "Detail: "
				<< (d && *d ? *d : "[no detail]") << std::endl;
			;
			}
		    }
		}
	    catch (int a)
		{
		if (a == 100)
		    std::clog << "ERRORE: endpoint non trovato" << std::endl;

		}

	    }
Пример #8
0
    void UserGetUri(struct soap *soap, struct _trt__GetProfilesResponse *trt__GetProfilesResponse,struct _tds__GetCapabilitiesResponse *capa_resp)  
    {  
	struct _trt__GetStreamUri *trt__GetStreamUri = (struct _trt__GetStreamUri *)malloc(sizeof(struct _trt__GetStreamUri));
	struct _trt__GetStreamUriResponse *trt__GetStreamUriResponse = (struct _trt__GetStreamUriResponse *)malloc(sizeof(struct _trt__GetStreamUriResponse));
        int result=0 ;  
        trt__GetStreamUri->StreamSetup = (struct tt__StreamSetup*)soap_malloc(soap,sizeof(struct tt__StreamSetup));//初始化,分配空间  
        trt__GetStreamUri->StreamSetup->Stream = 0;//stream type  
      
        trt__GetStreamUri->StreamSetup->Transport = (struct tt__Transport *)soap_malloc(soap, sizeof(struct tt__Transport));//初始化,分配空间  
        trt__GetStreamUri->StreamSetup->Transport->Protocol = 0;  
        trt__GetStreamUri->StreamSetup->Transport->Tunnel = 0;  
        trt__GetStreamUri->StreamSetup->__size = 1;  
        trt__GetStreamUri->StreamSetup->__any = NULL;  
        trt__GetStreamUri->StreamSetup->__anyAttribute =NULL;  
      
      
        trt__GetStreamUri->ProfileToken = trt__GetProfilesResponse->Profiles->token ;  
      
        printf("\n\n---------------Getting Uri----------------\n\n");  
      
        soap_wsse_add_UsernameTokenDigest(soap,"user", ONVIF_USER, ONVIF_PASSWORD);  
        soap_call___trt__GetStreamUri(soap, capa_resp->Capabilities->Media->XAddr, NULL, trt__GetStreamUri, trt__GetStreamUriResponse);  
      
      
        if (soap->error) {  
        printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));  
        result = soap->error;  
      
        }  
        else{  
            printf("!!!!NOTE: RTSP Addr Get Done is :%s \n",trt__GetStreamUriResponse->MediaUri->Uri);  
	    //最后我们使用vlc -vvv命令来打开一个rstp网络流
	    char cmd_str[256];
	    memset(cmd_str, 0, sizeof(cmd_str));
	    sprintf(cmd_str, "vlc %s --sout=file/ps:device%d.mp4", trt__GetStreamUriResponse->MediaUri->Uri, HasDev);
	    popen((const char *)cmd_str, "r");		
        }  
    }  
const char *RepositorySoapProxy::soap_fault_string()
{   return *soap_faultstring(this);
}
Пример #10
0
const char *UploaderSoapProxy::soap_fault_string()
{   return *soap_faultstring(this);
}
const char *enrimaSoap11Proxy::soap_fault_string()
{	return *soap_faultstring(this);
}
Пример #12
0
const char *SearchBindingProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
const char *RuleEngineBindingProxy::soap_fault_string()
{	return *soap_faultstring(this->soap);
}
const char *WsDfuServiceSoapProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
const char *RemoteDiscoveryBindingProxy::soap_fault_string()
{	return *soap_faultstring(this->soap);
}
Пример #16
0
const char *ReceiverBindingProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
const char *ws_USCOREaccountServiceSoapProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
Пример #18
0
const char *dpws_discoveryProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
Пример #19
0
const char *calcProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
const char *SealingServicesBindingProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
const char *OntologyQuerySoapBindingProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
Пример #22
0
const char *CRAB_ProxySOAPProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
const char *MemberServicesSoapProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
const char *CustomBinding_DumpUploadService3_UploaderProxy::soap_fault_string()
{   return *soap_faultstring(this);
}
Пример #25
0
const char *BESFactorySOAPBindingProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
Пример #26
0
const char *CS8ServerV1Proxy::soap_fault_string()
{	return *soap_faultstring(this);
}
Пример #27
0
int main(int argc, char *argv[]) {
    /* 变量声明 */
    struct soap *soap;  //soap环境变量      
    struct wsdd__ProbeType req;   //用于发送消息描述   
    struct wsdd__ProbeType wsdd__Probe;
    struct __wsdd__ProbeMatches resp;
    //struct wsdd__ProbeMatchesType resp; //请求消息的回应
    struct wsdd__ScopesType sScope; //描述查找哪类的Web服务
    struct SOAP_ENV__Header header; //soap消息头描述
    int count = 0;  //获得的设信息备个数
    int result = 0;    //返回值        
	unsigned char macaddr[6];  
	char _HwId[1024];  
	unsigned int Flagrand;

	// Create SessionID randomly  
	srand((int)time(0));  
	Flagrand = rand()%9000 + 8888;   
	macaddr[0] = 0x1;
	macaddr[1] = 0x2; 
	macaddr[2] = 0x3; 
	macaddr[3] = 0x4; 
	macaddr[4] = 0x5; 
	macaddr[5] = 0x6;  
	sprintf(_HwId,"urn:uuid:%ud68a-1dd2-11b2-a105-%02X%02X%02X%02X%02X%02X", Flagrand, macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);
    /************初始化*************/
    soap = soap_new(); //为soap申请变量空间,并初始化
    if ( soap == NULL) {
		return -1;
	}
    soap_set_namespaces(soap, namespaces); //设置soap的namespaces
    soap->recv_timeout = 5; //超过5秒钟没有数据就退出
    soap_default_SOAP_ENV__Header(soap, &header);//将header设置为soap消息    头属性
    header.wsa__MessageID = _HwId;
    header.wsa__To     = "urn:schemas-xmlsoap-org:ws:2005:04:discovery";
    header.wsa__Action = "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe";
    soap->header = &header; //设置soap头消息的ID
    //设置soap消息的请求服务属性
    soap_default_wsdd__ScopesType(soap, &sScope);
    sScope.__item = "";     
	//sScope.__item = "onvif://www.onvif.org";
    soap_default_wsdd__ProbeType(soap, &req);
    req.Scopes = &sScope;
    //req.Types = "tdn:NetworkVideoTransmitter";
    req.Types = "tds:Device";
    //调用gSoap接口
    //soap_wsdd_Probe
    result  = soap_send___wsdd__Probe(soap, "soap.udp://239.255.255.250:3702", NULL, &req);
    printf("%s: %d, send probe request success!\n",__FUNCTION__, __LINE__);
    if ( result == -1 ) {
        printf ( "soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));
        result = soap->error;
    } else {
        do {
            printf("%s: %d, begin receive probematch... \n",__FUNCTION__, __LINE__);
            printf("count=%d \n",count);
            //接收ProbeMatches,成功返回0,否则-1
            result = soap_recv___wsdd__ProbeMatches(soap, &resp);
            printf(" --soap_recv___wsdd__ProbeMatches() result=%d \n",result);
            if (result==-1) {
                printf("Find %d devices!\n", count);
                break;
            } else {                     
                //读取服务端回应的Probematch消息
				if ( resp.wsdd__ProbeMatches){
					/***
					printf("soap_recv___wsdd__Probe:  __sizeProbeMatch=%d\r\n",resp.wsdd__ProbeMatches->__sizeProbeMatch);
					printf("Target EP Address : %s\r\n",      resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address);
					printf("Target Type : %s\r\n",            resp.wsdd__ProbeMatches->ProbeMatch->Types);
					printf("Target Service Address : %s\r\n", resp.wsdd__ProbeMatches->ProbeMatch->XAddrs);
					printf("Target Metadata Version : %d\r\n",resp.wsdd__ProbeMatches->ProbeMatch->MetadataVersion);
					printf("Target Scopes Address : %s\r\n",  resp.wsdd__ProbeMatches->ProbeMatch->Scopes->__item);
					**/
					DeviceInfo device;
					device.dev_uuid = resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address;
					device.dev_server_address =  resp.wsdd__ProbeMatches->ProbeMatch->XAddrs;
					char duplicate = 0;
					int index = 0;
					while ( index < MAX_DEVICE) {
						char *uuid = g_device_list[ index].dev_uuid;
						if ( uuid != NULL && strcmp( uuid, device.dev_uuid) == 0 ) {
							duplicate = 1;
							break;
						}
						++index;
					}
					if ( duplicate == 0) {
						printf ( " find device no :%d  \n" , ( count +1));
						printf ( " uuid : %s  \n" , device.dev_uuid);
						printf ( " server address : %s  \n" , device.dev_server_address);
						g_device_list[ count] = device;
						count += 1;
					}
				}
            }
        } while ( 1);
    }
    //清除soap
    soap_end(soap); // clean up and remove deserialized data
    soap_free(soap);//detach and free runtime context
    soap_done(soap); // detach context (last use and no longer in scope)
    return result;
}
const char *ImagingBindingProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
const char *DoorControlBindingProxy::soap_fault_string()
{	return *soap_faultstring(this);
}
const char *WsAttributesServiceSoapProxy::soap_fault_string()
{	return *soap_faultstring(this);
}