working on it ...

Filters

Explore Public Snippets

Sort by

Found 227 snippets matching: webservice

    public by dave83  2746  0  6  3

    JAX-RS web service using Path annotation

    This simple code shows how to implement a JAX-RS rest web service. @Path annotation is used to bind URI pattern to a specific method. The web service path '/path' is the main root. On a GET request to URI '/path' the method getUser() will be invoked. On a GET request to URI '/path/test' the method getTest() will be invoked. In this simple j
    import javax.ws.*;
     
    @Path("/path")
    public class WebRestService {
     
    	@GET
    	public Response getUser() {
     
    		return Response.status(200).entity("get User is called").build();
     
    	}
     
    	@GET
    	@Path("/test")
    	public Response getTest() {
     
    		return Response.status(200).entity("get Test is called").build();
     
    	}
    }

    external by Bhupinderjit Singh  290  0  3  0

    Signup webservice sample #signup #webservice #sample

    Signup webservice sample #signup #webservice #sample: signup.php
    <?php
    
    	include_once("config.php");
    
    	// array for JSON response
    	$response = array();
    	$json_status = null;
    	$json_cust_data = null;
    
    	$cust_first_name = $_POST['cust_first_name'];
    	$cust_last_name = $_POST['cust_last_name'];
    	$cust_email = $_POST['cust_email'];
    	$cust_pass = $_POST['cust_pass'];
    	$cust_gender = $_POST['cust_gender'];
    	$cust_phone_number1 = $_POST['cust_phone_number1'];
    	$cust_phone_number2 = $_POST['cust_phone_number2'];
    	$cust_profile_image = $_POST['cust_profile_image'];
    	
    	
    	/*$cust_first_name = 'Mohit';
        $cust_last_name = 'kumar';
    	$cust_email = 'nk@nettechnocrats.com';
    	$cust_pass='admin@123';
    	$cust_gender = 'Male';
    	$cust_phone_number1 = '7503338587';
    	$cust_phone_number2 = '9498494';
    	$cust_profile_image = 'mk.jpeg';*/
    	
    	
    	
    
    
    	if($cust_first_name=='') {
    		  
    		  $json_status = array("Code" => "Error","Reason" => "First name is missing", "Message" => "");
    		  
    		  $json_cust_data = null;
    	}
    	else if ($cust_email=='') {
    		  
    		 $json_status = array("Code" => "Error","Reason" => "Email id is missing", "Message" => "");
    		 
    		 $json_cust_data = null;
    	}
    	else if ($cust_phone_number1=='') {
    		  
    		 $json_status = array("Code" => "Error", "Reason" => "Phone number is missing", "Message" => "");
    		 
    		 $json_cust_data = null;
    		 
    	}
    	else  {
    		
    			
    			$cur_dat=date('Y-m-d h:i:s');
    		    
    			
    
    		     $email_already_sql = mysql_query("SELECT cust_email FROM customer WHERE cust_email = '".$cust_email."'");
    	
    	         if(mysql_num_rows($email_already_sql)>0)
    	         {
    		      
    				  
    				  $json_status = array("Code" => "Error", "Reason" => "This email id is already exists", "Message" =>"");
    				  
    				  $json_cust_data = null;
    	         }
    	         else
    	         {
                 
                 
                  $result= mysql_query("insert into customer set cust_first_name='".$cust_first_name."',cust_last_name='".$cust_last_name."',	cust_gender='".$cust_gender."',cust_email='".$cust_email."',cust_phone_number1='".$cust_phone_number1."',cust_phone_number2='".$cust_phone_number2."',cust_profile_image='".$cust_profile_image."',cust_created='".$cur_dat."' ,cust_pass='".$cust_pass."'") or die ("Error: ".mysql_error());
    
    
    	             if($result>0)
    	             {
    	   	            $cust_id=mysql_insert_id();
    					
    					$json_status = array("Code" => "Success","Reason" => "", "Message" => "Inserted");
    					
    					$json_cust_data = array("cust_id"=>$cust_id);
    	             } else {
    						$json_status = array("Code" => "Error", "Reason" => "", "message" => "Something is missing");
    						
    						$json_cust_data = null;
    	       
    						}  
    	         }  
    
    	}
    	 
    	echo json_enCode(array('Status'=>$json_status,'Data'=>$json_cust_data)); 
    ?>
    
    

    external by iamjono  281  0  3  0

    This Lasso 9 data type uses the JSON Webservice of http://www.geoplugin.com/ to geolocate IP addresses. See http://www.geoplugin.com/webservices/ for more specific details of this free service.

    This Lasso 9 data type uses the JSON Webservice of http://www.geoplugin.com/ to geolocate IP addresses. See http://www.geoplugin.com/webservices/ for more specific details of this free service.: geoplugin.lasso
    [
    	// ==================================
    	/*
    		@author Jonathan Guthrie (jono@treefrog.ca)
    		#version 1.00
    		
    		This Lasso 9 data type uses the JSON Webservice of http://www.geoplugin.com/ to geolocate IP addresses
    		See http://www.geoplugin.com/webservices/ for more specific details of this free service
    		
    		Usage:
      		local(userLocation = geoPlugin)
      		#userLocation->locate(web_request->remoteAddr)
      		#userLocation->city
      		#userLocation->countryCode
      		...
    	*/
    	// ==================================
    
    
    define geoPlugin => type {
    	
    	//the geoPlugin server
    	data private host::string = 'http://www.geoplugin.net/json.gp?ip={IP}&base_currency={CURRENCY}'
    		
    	//the default base currency
    	data 
    		public currency::string = 'CAD'
    	
    	//initiate the geoPlugin vars
    	 data
    		public ip::string 					= '',
    		public city::string 				= '',
    		public region::string 				= '',
    		public areaCode::string 			= '',
    		public dmaCode::string 				= '',
    		public countryCode::string 			= '',
    		public countryName::string 			= '',
    		public continentCode::string 		= '',
    		public latitude::decimal 			= 0.000000,
    		public longitude::decimal 			= 0.000000,
    		public currencyCode::string 		= '',
    		public currencySymbol::string 		= '',
    		public currencyConverter::decimal 	= 1.000000
    
    	public locate(ip::string='') => {
    		
    		#ip->size == 0 ? #ip = string(client_ip)
    		.ip = #ip
    		
    		.host->replace('{IP}',#ip)
    		.host->replace('{CURRENCY}',.currency)
    		
    		local(data = array)
    		local(response = string(include_url(.host)))
    		#response->removeleading('geoPlugin(')
    		#response->removetrailing(')')
    		
    		#response >> 'temporarily blacklisted' ? log_critical(#response)
    			
    		#data = json_deserialize(#response)
    
    //		//set the geoPlugin vars
    		if(not #data->isA(::void)) => {
    			.city 				= string(#data->find('geoplugin_city'))
    			.region 			= string(#data->find('geoplugin_region'))
    			.areaCode 			= string(#data->find('geoplugin_areaCode'))
    			.dmaCode 			= string(#data->find('geoplugin_dmaCode'))
    			.countryCode 		= string(#data->find('geoplugin_countryCode'))
    			.countryName 		= string(#data->find('geoplugin_countryName'))
    			.continentCode 		= string(#data->find('geoplugin_continentCode'))
    			.latitude 			= decimal(#data->find('geoplugin_latitude'))
    			.longitude 			= decimal(#data->find('geoplugin_longitude'))
    			.currencyCode 		= string(#data->find('geoplugin_currencyCode'))
    			.currencySymbol 	= string(#data->find('geoplugin_currencySymbol'))
    			.currencyConverter 	= decimal(#data->find('geoplugin_currencyConverter'))
    		}
    	}
    	
    
    	public convert(amount::decimal, float::integer=2, symbol::boolean=true) => {
    		
    		//easily convert amounts to geolocated currency.
    		local(out =  decimal(#amount * .currencyConverter)->asString(-precision=#float))
    		if(#symbol == true) => {
    			return (.currencySymbol + #out)
    		} else {
    			return #out
    		}
    	}
    	public convert(amount::any, float::integer=2, symbol::boolean=true) => {
    		return ('geoPlugin Warning: The amount passed to geoPlugin::convert is not a decimal.')
    	}
    }
    ]
    
    

    external by Bhupinderjit Singh  229  0  3  0

    Login webservice sample #login #webservice

    Login webservice sample #login #webservice: loginwebservice.php
    <?php
     
       include("config.php");
    
    ?>
    
    <?php
    
      error_reporting(0);
    
      $email = $_POST['cust_email'];
      $pass = $_POST['cust_pass'];
    
      $fetch_details = "select * from customer where cust_email='".$email."' and cust_pass='".$pass."'";
      $sql = mysql_query($fetch_details);
      $data = mysql_fetch_array($sql);
      
      
      $cust_id = $data['cust_id'];
      $cust_first_name = $data['cust_first_name'];
      $cust_last_name = $data['cust_last_name'];
      
      
      
    	 if($data) 
         {
    	     			
    			$json_status = array( "Code" => "Success","Reason" => "", "Message" => "");
    	      $json_cust_data =array("cust_id" => $cust_id,
    	        								 "cust_first_name" => $cust_first_name,
    	        								 		"cust_last_name" => $cust_last_name);
    	 }
    	 
    	 else
    	 {
    		
    		   $json_status = array("Code" => "Error", "Reason" => "Wrong Email Id  OR Password", "Message" => "Please enter correct Email and Password");
    	      $json_cust_data = null;
    		 
    	 }
    	  
     @mysql_close($conn);
     
     echo json_encode(array('Status' => $json_status, 'Data' => $json_cust_data)); 
    
    ?>
    
    
    
    

    external by Altherlex Alves  148  2  2  0

    How to consuming a Qualitor WebService

    How to consuming a Qualitor WebService: clisoap-qualitor.rb
    # Calling into cmd line (ShellScipt or PowerShell):
    #   ./clisoap-qualitor.rb config-file.yml
    require 'savon'
    require 'yaml'
    config = YAML::load( File.open(ARGV[0]) )
    conn = Savon.client(wsdl:config["url"])
    auth = conn.call(:login, message:{login:config["login"], passwd:config["passwd"], company:config["company"]})
    # TIP: HOW TO KEEP SESSION WHEN CONSUMING A SOAPCLIENT WITH SAVON v.2
    # It's necessary to maintain the session with option: "cookies:auth.http.cookies"
    r = conn.call(config["method"].to_sym, message: {auth:auth.body[:login_response][:result], xmlValue:config["xml"]}, cookies:auth.http.cookies)
    puts r.body
    
    ##### Exemple config-file.yml  #####
    url: http://youcompany.qualitor.com/ws/services/service.php?wsdl=WSTicket
    login: user
    passwd: 123
    company: 1
    method: close_ticket
    xml: <wsqualitor><contents><data><cdchamado>126648</cdchamado><idfecharrelacionados>Y</idfecharrelacionados></data></contents></wsqualitor>
    
    
    
    
    

    external by Alan Viars  137  0  2  0

    Direct Certificate Discovery RESTFul Webservice

    Direct Certificate Discovery RESTFul Webservice: gistfile1.md
    Direct Certificate Download and Discovery as a RESTFul Webservice
    =================================================================
    
    This document describes how to use the Direct Certificate Discovery API for fetching (downloading) certificates and validating if and how the certificates were discovered.
    
    
    Certificate Fetching
    ===================
    
    This tool downloads the certificate itself to your web client.
    
    
    Format:
    
    
          https://eapi.npi.io/api/get-direct-endpoint-certificate/[ENDPOINT]
        
    
    
    Example 1 - Get the Certificate as ASCII Text
    ---------------------------------------------
    
    To get the x509 Certificate if it exists:
    
        https://eapi.npi.io/api/get-direct-endpoint-certificate/bill@hit-testing.nist.gov
    
    Output:
    
        -----BEGIN CERTIFICATE-----
        MIIEJTCCAw2gAwIBAgIBBjANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQGEwJVUzELMAkGA1UECAwC
        TUQxFTATBgNVBAcMDEdhaXRoZXJzYnVyZzENMAsGA1UECgwETklTVDERMA8GA1UEAwwIbmlzdC5n
        b3YxFzAVBgkqhkiG9w0BCQEWCG5pc3QuZ292MB4XDTE0MDQwMjE0MDEyOFoXDTE2MDQwMTE0MDEy
        OFowgYQxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJNRDEVMBMGA1UEBwwMR2FpdGhlcnNidXJnMQ0w
        CwYDVQQKDAROSVNUMR0wGwYDVQQDDBRoaXQtdGVzdGluZy5uaXN0LmdvdjEjMCEGCSqGSIb3DQEJ
        ARYUaGl0LXRlc3RpbmcubmlzdC5nb3YwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQ
        2Dhq3mH3zkl+8gmELWdVA5ZpPoSS0dyl0RuBt+UceP3w2fQHHOkSj92ZGjpSMWbrXtlsFa2daVGZ
        2EDjv5EpDTw55U7rSuD1S7scpmsYL7w3RhfFfhF2KLc63Z3v7EaVhp3Bora7kMJMSIlPrvIuQFTA
        zBy7Lbal9PiMPOuiPdrcon5OMDg7JOVBFyzq1bq0pm82q2PPPoXymHLXKfsBT0jjNtnKSFSJe12n
        2ibYqgk+T7XaRjaBCDyMkKfAkRI348zhFW7BgRnIUW+2hePQTleAYzci/AGSpbKrt5Ary9PDYCBC
        WHvbQdi9Cv7BGSCF+4xWPS9X9b9dE/wKX43RAgMBAAGjgbgwgbUwCQYDVR0TBAIwADAfBgNVHREE
        GDAWghRoaXQtdGVzdGluZy5uaXN0LmdvdjAdBgNVHQ4EFgQUi2D+g5UA4HxZB+1WQ3TKhE26cEUw
        HwYDVR0jBBgwFoAU2b5OviFqiWCvpYQPeeWHf/+8RF0wCwYDVR0PBAQDAgWgMDoGA1UdHwQzMDEw
        L6AtoCuGKWh0dHA6Ly9zYW1wbGVjYS5uaXN0Lmdvdi9jcmwvbmlzdC5nb3YuY3JsMA0GCSqGSIb3
        DQEBCwUAA4IBAQC1kG1vB0xMasYozmduZiqmM2lqYtXKw5t9pIBB+VqAweg7d29gQMF2/5c6ZKRZ
        FGdcWY04EOYIM88qitqEfgebe4eEX2NmyGreCJL/RH7Cl0ex5vbospL0uCO4NulRg/hFoOKOEkFD
        bL33Zj57kRvjK5WcvmtQe1rO/QuV5+n1+MGjy2+BPzPqXNqZRz8N8XSkKfLf0K3OlLHSItgCrvWo
        5JXGI0AZRVF4qxb6qgkywpRGu8LRs5qKQyzpJ91vZiLr/5ARhPsEKImEXb4VQqD8UgkeSxUHnyQV
        GneC5c7K3HW1/GmvYwTybLeDM+mnDzKD/6Nb2qXTUffHoTWtHF8M
        -----END CERTIFICATE-----
    
    
    
    Example 2 - No Certificate Found
    --------------------------------
    
    If it doesn't exist, then you'll get an error message.  For example:
    
    
        https://eapi.npi.io/api/get-direct-endpoint-certificate/foo@example.com
    
    Output:
     
    
        No certificate was found via LDAP or DNS.
        
    
    
    Example 3 - Get the Certificate as a .pem File
    ----------------------------------------------
    
    Just add ".pem" to then end of the endpoint to get a PEM file instead of text.
    
    
        https://eapi.npi.io/api/get-direct-endpoint-certificate/bill@hit-testing.nist.gov.pem
    
    
    This will download a pem file with content_type="application/x-pem-file".
    
    
    Certificate Validation
    ======================
    
    This URL returns a JSON document containing information on whether or not the certificate 
    was found and wheather it was found in DNS or LDAP. 
    
    Format:
    
    
        https://eapi.npi.io/api/validate-direct-endpoint/[ENDPOINT]
        
    
    Example 4: A certificate was found in LDAP
    ------------------------------------------
    
    Search for the certificate for the endpoint "domain2.demo.direct-test.com"
    
    
        https://eapi.npi.io/api/validate-direct-endpoint/domain2.demo.direct-test.com
    
    Output:
    
    
        {
        is_found: true,
        dns: {
             status: 404,
             message: "No Answer.",
             is_found: false,
             details: "The server did not provide an answer. No certificate found."
             },
         ldap: {
               status: 200,
               message: "The certificate domain2.demo.direct-test.com was found.",
               is_found: true
               }
        }
    
    
    Example 5: No certificate was found
    ------------------------------------
    
    Search for the certificate for the endpoint "foo@example.com".
    
    
        https://eapi.npi.io/api/validate-direct-endpoint/foo@example.com
    
    Output:
    
    
        {
        is_found: false,
        dns: {
             status: 404,
             details: "No DNS server found.",
             message: "Certificate not found.",
             is_found: false
             },
        ldap: {
              status: 404,
              details: "No LDAP server was found.",
              message: "No certificate found.",
              is_found: false
              }
        }
    
    

    external by Erich Nascimento  57  0  1  0

    Exemplo de consumo do webservice do Selecty via PHP/JSON

    Exemplo de consumo do webservice do Selecty via PHP/JSON: selecty-webservice.php
    PHP
    #!/usr/bin/env php
    <?php
    
    /**
     * Testa Selecty webservices
     * 
     * @author  Erich Nascimento <erich@youse.com.br>
     * @copyright Youse Technologies
     */
     
     // URL Base
    $base = 'http://globalempregos.selecty.com.br/ws/amfphp/json.php';
    $base = 'http://youcloud-srv/ws/amfphp/json.php';
    
    
     // URL do serviço de autenticação
    $authenticationService = 'system.youcloud.AuthenticationService.authenticationHost';
    $paramHostName = 'globalempregos.selecty.com.br';
    $paramHostName = 'youcloud-srv';
    
    //
    // Invoca o serviço de autenticação e armazena a chave de acesso
    // 
    echo "Autenticando na plataforma...\n";
    $authKey = file_get_contents(
        $base . '/' .
        $authenticationService . '/' .
        $paramHostName
    );
    // Como é um JSON, o mesmo DEVE ser decodificado
    $authKey = json_decode($authKey);
    
    echo "A chave de acesso dada foi: $authKey \n";
    echo "\n";
    echo "\n";
    
    
    //
    // Invoca o serviço de estatística de vagas
    // Repare que precisamos do $authKey
    // 
    
    // URL do serviço de estatística de vagas
    $statisticService = 'hr.CurriculumWebService.getVacancyStatistics';
    // Pode ser: "area", "city" ou "occupation"
    $param1 = 'city';
    // Pode ser "emprego", "estagio" ou "null"
    $param2 = 'null';
    
    echo "\n";
    // Invoca o serviço de autenticação e armazena a chave de acesso
    echo "Obtendo a estatistica de vagas por cidade ($param1)...\n";
    $statistics = file_get_contents(
        $base . '/' .
        $statisticService . '/' .
        $param1 . '/' . 
        $param2 . '/?' . 
        'authKey=' . urlencode($authKey)
    );
    // Decodifica a string JSON
    $statistics = json_decode($statistics);
    
    $totalVacancies = 0;
    foreach ($statistics as $value) 
    {
        $totalVacancies+=$value->quantity;
        echo sprintf("\n%s (%s)", $value->label, $value->quantity);
    }
    
    echo sprintf("\n\nTotal de vagas por cidade: %s vagas\n", $totalVacancies);
    
    
    echo "\n";
    echo "\n";
    
    
    //
    // Invoca o serviço que obtem as vagas
    // Repare que precisamos do $authKey
    // 
    
    // URL do serviço de estatística de vagas
    $vacancyService = 'hr.CurriculumWebService.getVacanciesByCriteria';
    // O filtro desejado
    $param1 = '{"area": "TI"}';
    
    // Total de registros por requisição
    $param2 = 10;
    
    // Offset (página)
    $param3 = 0;
    
    // Invoca o serviço de autenticação e armazena a chave de acesso
    echo "\nObtendo vagas que sejam da área de TI ($param1)...\n";
    $itVacancies = file_get_contents(
        $base . '/' .
        $vacancyService . '/' .
        urlencode($param1) . '/' . 
        $param2 . '/' . 
        $param3 . '/?' . 
        'authKey=' . urlencode($authKey)
    );
    // decodifica o resultado
    $itVacancies = json_decode($itVacancies);
    
    echo sprintf("\nTotal de vagas encontradas: %d vagas\n", count($itVacancies));
    
    foreach ($itVacancies as $value) 
    {
        echo sprintf("\n%d vaga(s) para %s em %s - %s", $value->totalVacancies, $value->occupation, $value->city, $value->state);
    }
    
    echo "\n";
    echo "\n";
    
    
    

    external by DausukeTsujita  57  0  1  0

    WebService by gawk and bash. Please make response.txt include HTTP Responce Header.

    WebService by gawk and bash. Please make response.txt include HTTP Responce Header.: WebServer
    #!/bin/bash
    
    while :
    do
      echo "=== WebServer Start and Listen ==="
      gawk 'BEGIN{ \
        SOCK="/inet/tcp/80/0/0"; \
          body_size=0; \
          #request head \
          while( (SOCK |& getline REQ) > 0){ \
            print REQ; \
            if( REQ~/^Content-Length/ ){ \
              split(REQ,cl,":"); \
              body_size=cl[2]; \
            } \
            if( REQ=="\r" ){ break; } \
          } \
          #request body \
          recive_size=0; \
          if(body_size > 0){ \
            while( (SOCK |& getline REQ) > 0){ \
              print REQ; \
              recive_size=recive_size + length(REQ) + 1; \
              if(recive_size >= body_size){ break; } \
            } \
          } \
          #response \
          RES_TXT="./response.txt"; \
          while( getline line < RES_TXT > 0){ \
            print line |& SOCK; \
          }\
          close(RES_TXT); \
        close(SOCK); \
      }'
    done
    
    

    external by David Healy  57  0  1  0

    Naive WebService Request

    Naive WebService Request: gistfile1.scala
    def getUserData(userId: Int): Future[JsValue] = {
      val request = WS.url("http://example.com/user/1").withHeaders("Content-Type" -> "application/json").get()
      
      request.map { response =>
        if (response.status == 200) {
          response.json
        } else {
          throw new Exception("Error received. Status: ${response.status} Body: ${response.json}")
        }
      }
    }
    
    

    external by Alexander Ti  57  0  1  0

    Revmove jaxbelement in generated webservice client java classes

    Revmove jaxbelement in generated webservice client java classes: bindings.xjb
    <?xml version="1.0" encoding="UTF-8"?>
    
    <jaxb:bindings
      xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
      xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc">
    
      <jaxb:globalBindings generateElementProperty="false">
        <xjc:simple />
      </jaxb:globalBindings>
    </jaxb:bindings>
    
    
    • Public Snippets
    • Channels Snippets