working on it ...

Filters

Explore Public Snippets

Sort by

Found 47 snippets matching: webservices

    public by dave83 modified Mar 26, 2014  2710  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 submarines-and modified Apr 7, 2015  57  0  1  0

    Webservices T4 - Guide

    Webservices T4 - Guide: gistfile1.txt
    *) Setup
        1) Program and Features ---> Turn windows features on or off
        2) Markera följande val:
            a) world-wide web services --> application devlopment features --> asp.net 4.5
            b) world-wide web services --> web management tools --> iis management console
      
    *) Server (IIS)
        1) Starta visual studio som admin
        2) Skapa ett nytt projekt (new --> web site --> asp.net web application ---> välj empty)
        3) Lägg till en webservice (add --> new item --> web service (asmx)
        4) Det skapas en webmetod som returnerar "hello world", ändra den till något skoj och bygg/kör projektet
        5) Skriv new länken som metoden publiceras under 
            (exempel: http://localhost:20266/WebService1.asmx )
      
    *) Klient (C#)
        1) Skapa ett nytt projekt (console application eller windows forms application)
        2) Högerklicka på projektet, välj add --> service reference
        3) Skriv antingen in din sparade länk, eller tryck discover
        4) Välj din webservice, döp referensen till något roligt och tryck ok
        5) Instansiera en klient (ReferensNamn.WebServiceNamnSoapClient client = new .... )
            (exempel: ServiceReference2.WebService1SoapClient client = new ServiceReference2.WebService1SoapClient(); )
        6) Testa att invokera din metod (client.HelloWorld(); )
      
    *) Klient (Java)
        1) Skapa ett nytt projekt i eclipse
        2) Skapa en web service (new --> other --> web services --> web service client)
        3) Klistra antingen in din gamla länk med "?wdsl" på slutet, eller tryck på browse och leta upp den
            (exempel: http://localhost:20266/WebService1.asmx?wdsl)
        4) Dra new slidern till vänster längst new (Develop client)
        5) Tryck finish
        6) Instansiera en proxy (ReferensNamnSoapProxy)
            (exempel: WebService1SoapProxy client = new WebService1SoapProxy(); )
        7) Invokera webmetoden (client.helloWorld(); ) - troligtvis krävs try catch
      
      
    
    
    

    external by ThiagoAnunciacao modified Jun 25, 2014  2666  13  4  0

    WebServices Bovespa

    WebServices Bovespa: gistfile1.txt
    # Retorna dados sobre o pregão
    http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoCarregarDados.asp?CodDado=IBOV,ticker&CA=undefined
    
    # Retorna ações e seus últimos valores negociados
    http://www.bmfbovespa.com.br/Pregao-OnLine/ExecutaAcaoCarregarDados.asp?CodDado=Ticker
    
    # Retorna o histórico do dia de um papel
    http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoCarregarDadosPapeis.asp?CodDado=petr4
    
    # Retorna dados de um papel
    http://www.bmfbovespa.com.br/cotacoes2000/formCotacoesMobile.asp?codsocemi=PETR4
    
    # Retorna array com vários papeis
    http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoAjax.asp?CodigoPapel=BISA3|PETR4|BBDC4
    
    # Retorna dados do pregão
    http://www.bmfbovespa.com.br/cotacoes2000/formCotacoesMobile.asp?codsocemi=IBOV
    
    
    

    external by Rahul modified May 24, 2015  34  0  1  0

    simple class which helpful writing webservices

    simple class which helpful writing webservices: class.responseHandler.php
    <?php
    class ResponseHandler {
    	private static $_instance;
    	private $_api_response_code;
    	private $_api_response;
    	
    	// create new instance of class
    	public static function singleInstance() {
    		if (! self::$_instance) {
    			self::$_instance = new self ();
    		}
    		return self::$_instance;
    	}
    	private function __construct() {
    		$this->_api_response_code = array (
    				0 => array (
    						'HTTP Response' => 400,
    						'Message' => 'Unknown Error' 
    				),
    				1 => array (
    						'HTTP Response' => 200,
    						'Message' => 'Success' 
    				),
    				2 => array (
    						'HTTP Response' => 403,
    						'Message' => 'HTTPS Required' 
    				),
    				3 => array (
    						'HTTP Response' => 401,
    						'Message' => 'Authentication Required' 
    				),
    				4 => array (
    						'HTTP Response' => 401,
    						'Message' => 'Authentication Failed' 
    				),
    				5 => array (
    						'HTTP Response' => 404,
    						'Message' => 'Invalid Request' 
    				),
    				6 => array (
    						'HTTP Response' => 400,
    						'Message' => 'Invalid Response Format' 
    				) 
    		);
    	}
    	/**
    	 *
    	 * @param string $reponseFormate The desired HTTP response content type: [json, html, xml]
    	 * @param int $responseCode The desires reponse for api
    	 * @param $data $api_response The desired HTTP response data
    	 */
    	public function deliver($reponseFormate, $responseCode, $data) {
    		$response ['code'] = $responseCode;
    		$response ['status'] = $this->_api_response_code [$response ['code']] ['HTTP Response'];
    		$response ['status_message'] = $this->_api_response_code [$response ['code']] ['Message'];
    		$response ['data'] = $data;
    		// Return Response to browser. This will exit the script.
    		$this->deliver_response ( $reponseFormate, $response );
    	}
    	/*
    	 * @param string $format The desired HTTP response content type: [json, html, xml]
    	 * @param string $api_response The desired HTTP response data
    	 * @return void
    	 */
    	function deliver_response($format, $api_response) {
    		
    		// Define HTTP responses
    		$http_response_code = array (
    				200 => 'OK',
    				400 => 'Bad Request',
    				401 => 'Unauthorized',
    				403 => 'Forbidden',
    				404 => 'Not Found' 
    		);
    		
    		// Set HTTP Response
    		@header ( 'HTTP/1.1 ' . $api_response ['status'] . ' ' . $http_response_code [$api_response ['status']] );
    		
    		// Process different content types
    		if (strcasecmp ( $format, 'json' ) == 0) {
    			
    			// Set HTTP Response Content Type
    			header ( 'Content-Type: application/json; charset=utf-8' );
    			
    			// Format data into a JSON response
    			$json_response = json_encode ( $api_response );
    			
    			// Deliver formatted data
    			echo $json_response;
    		} elseif (strcasecmp ( $format, 'xml' ) == 0) {
    			
    			// Set HTTP Response Content Type
    			header ( 'Content-Type: application/xml; charset=utf-8' );
    			// Format data into an XML response (This is only good at handling string data, not arrays)
    			$xml_response = $this->toXml($api_response,'response');
    			// Deliver formatted data
    			
    			echo $xml_response;
    		} else {
    			// Set HTTP Response Content Type (This is only good at handling string data, not arrays)
    			@header ( 'Content-Type: text/html; charset=utf-8' );
    			
    			// Deliver formatted data
    			echo empty ( $api_response ['data'] ) ? $api_response ['status_message'] : $api_response ['data'];
    		}
    		
    		// End script process
    		exit ();
    	}
    	
    	/*
    	 * The main function for converting to an XML document. Pass in a multi dimensional array and this recrusively 
    	 loops through and builds up an XML document.
    	 @param array $data @param string $rootNodeName - what you want the root node to be - defaultsto data. 
    	 @param SimpleXMLElement $xml - should only be used recursively @return string XML
    	 */
    	public static function toXml($data, $rootNodeName = 'data', $xml = null) {
    		// turn off compatibility mode as simple xml throws a wobbly if you don't.
    		if (ini_get ( 'zend.ze1_compatibility_mode' ) == 1) {
    			ini_set ( 'zend.ze1_compatibility_mode', 0 );
    		}
    		
    		if ($xml == null) {
    			$xml = simplexml_load_string ( "<?xml version='1.0' encoding='utf-8'?><$rootNodeName />" );
    		}
    		
    		// loop through the data passed in.
    		foreach ( $data as $key => $value ) {
    			// no numeric keys in our xml please!
    			if (is_numeric ( $key )) {
    				// make string key...
    				$key = "unknownNode_" . ( string ) $key;
    			}
    			
    			// replace anything not alpha numeric
    			$key = preg_replace ( '/[^a-z]/i', '', $key );
    			
    			// if there is another array found recrusively call this function
    			if (is_array ( $value )) {
    				$node = $xml->addChild ( $key );
    				// recrusive call.
    				ResponseHandler::toXml ( $value, $rootNodeName, $node );
    			} else {
    				// add single node.
    				$value = htmlentities ( $value );
    				$xml->addChild ( $key, $value );
    			}
    		}
    		// pass back as string. or simple xml object if you want!
    		return $xml->asXML ();
    	}
    }
    
    ?>
    
    
    

    external by Github modified Jun 15, 2016  22  0  1  0

    A jiffy bag <a href=" http://headtrash.co.uk/buy-cheap-clomid-online-uk.pdf ">private prescription for clomid uk</a> After years of being dismissed as a supplier of onlinecomputer services to startups and small businesses, Amazon WebServices (AWS) bea...

    A jiffy bag private prescription for clomid uk After years of being dismissed as a supplier of onlinecomputer services to startups and small businesses, Amazon WebServices (AWS) beat out International Business Machines this year to snag a $600 million contract with the CentralIntelligence Agency. : Maria
    A jiffy bag <a href=" http://headtrash.co.uk/buy-cheap-clomid-online-uk.pdf ">private prescription for clomid uk</a>  After years of being dismissed as a supplier of onlinecomputer services to startups and small businesses, Amazon WebServices (AWS) beat out International Business Machines this year to snag a $600 million contract with the CentralIntelligence Agency.
     
    
    

    external by Supun Lakshan Wanigarathna Dissanayake modified Oct 19, 2014  11  0  1  0

    Perform basic network operations with RESTful webservices

    Perform basic network operations with RESTful webservices: AbstractController.java
    import android.content.Context;
    import com.xfinity.ceylon_steel.util.InternetObserver;
    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.client.HttpClient;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.entity.ContentType;
    import org.apache.http.entity.mime.MultipartEntityBuilder;
    import org.apache.http.entity.mime.content.FileBody;
    import org.apache.http.entity.mime.content.StringBody;
    import org.apache.http.impl.client.DefaultHttpClient;
    import org.json.JSONArray;
    import org.json.JSONException;
    import org.json.JSONObject;
     
    import java.io.*;
    import java.net.UnknownHostException;
    import java.util.HashMap;
     
    /**
     * @author Supun Lakshan Wanigarathna Dissanayake
     * @mobile +94711290392
     * @email supunlakshan.xfinity@gmail.com
     */
    abstract class AbstractController {
     
        protected AbstractController() {
        }
     
        protected final static JSONObject getJsonObject(String url, HashMap<String, Object> parameters, Context context) throws IOException, JSONException, UnknownHostException {
            if (InternetObserver.isConnectedToInternet(context)) {
                HttpClient httpClient = new DefaultHttpClient();
                HttpPost postRequest = new HttpPost(url);
                if (parameters != null) {
                    MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
                    for (String parameter : parameters.keySet()) {
                        Object paramValue = parameters.get(parameter);
                        if (paramValue instanceof File) {
                            FileBody fileContent = new FileBody((File) paramValue, ContentType.MULTIPART_FORM_DATA);
                            multipartEntityBuilder.addPart(parameter, fileContent);
                        } else if (paramValue instanceof JSONObject || paramValue instanceof JSONArray) {
                            StringBody json = new StringBody(paramValue.toString(), ContentType.APPLICATION_JSON);
                            multipartEntityBuilder.addPart(parameter, json);
                        } else {
                            StringBody param = new StringBody(paramValue.toString(), ContentType.DEFAULT_TEXT);
                            multipartEntityBuilder.addPart(parameter, param);
                        }
                    }
                    HttpEntity httpPostParameters = multipartEntityBuilder.build();
                    postRequest.setEntity(httpPostParameters);
                }
                HttpResponse response = httpClient.execute(postRequest);
                BufferedReader bufferedReader = null;
                String lineSeparator = System.getProperty("line.separator");
                String responseString = "";
                try {
                    InputStream content;
                    if ((content = response.getEntity().getContent()) == null) {
                        return null;
                    }
                    bufferedReader = new BufferedReader(new InputStreamReader(content));
                    String currentLine;
                    while ((currentLine = bufferedReader.readLine()) != null) {
                        responseString = responseString + currentLine + lineSeparator;
                    }
                    return new JSONObject(responseString);
                } finally {
                    if (bufferedReader != null) {
                        bufferedReader.close();
                    }
                }
            }
            return null;
        }
     
        protected final static JSONArray getJsonArray(String url, HashMap<String, Object> parameters, Context context) throws IOException, JSONException, UnknownHostException {
            if (InternetObserver.isConnectedToInternet(context)) {
                HttpClient httpClient = new DefaultHttpClient();
                HttpPost postRequest = new HttpPost(url);
                if (parameters != null) {
                    MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
                    for (String parameter : parameters.keySet()) {
                        Object paramValue = parameters.get(parameter);
                        if (paramValue instanceof File) {
                            FileBody fileContent = new FileBody((File) paramValue, ContentType.MULTIPART_FORM_DATA);
                            multipartEntityBuilder.addPart(parameter, fileContent);
                        } else if (paramValue instanceof JSONObject || paramValue instanceof JSONArray) {
                            StringBody json = new StringBody(paramValue.toString(), ContentType.APPLICATION_JSON);
                            multipartEntityBuilder.addPart(parameter, json);
                        } else {
                            StringBody param = new StringBody(paramValue.toString(), ContentType.DEFAULT_TEXT);
                            multipartEntityBuilder.addPart(parameter, param);
                        }
                    }
                    HttpEntity httpPostParameters = multipartEntityBuilder.build();
                    postRequest.setEntity(httpPostParameters);
                }
                HttpResponse response = httpClient.execute(postRequest);
                BufferedReader bufferedReader = null;
                String lineSeparator = System.getProperty("line.separator");
                String responseString = "";
                try {
                    InputStream content;
                    if ((content = response.getEntity().getContent()) == null) {
                        return null;
                    }
                    bufferedReader = new BufferedReader(new InputStreamReader(content));
                    String currentLine;
                    while ((currentLine = bufferedReader.readLine()) != null) {
                        responseString = responseString + currentLine + lineSeparator;
                    }
                    System.out.println(responseString);
                    return new JSONArray(responseString);
                } finally {
                    if (bufferedReader != null) {
                        bufferedReader.close();
                    }
                }
            }
            return null;
        }
     
    }
    
    

    external by Github modified Jan 4, 2016  11  0  1  0

    What do you do? <a href=" http://www.asesoresdr.com.mx/zyban-buprpin-hydrchlride.pdf ">chantix zyban cst</a> After years of being dismissed as a supplier of onlinecomputer services to startups and small businesses, Amazon WebServices (AWS) beat out In...

    What do you do? chantix zyban cst After years of being dismissed as a supplier of onlinecomputer services to startups and small businesses, Amazon WebServices (AWS) beat out International Business Machines this year to snag a $600 million contract with the CentralIntelligence Agency. : Wilbert
    What do you do? <a href=" http://www.asesoresdr.com.mx/zyban-buprpin-hydrchlride.pdf ">chantix zyban cst</a>  After years of being dismissed as a supplier of onlinecomputer services to startups and small businesses, Amazon WebServices (AWS) beat out International Business Machines this year to snag a $600 million contract with the CentralIntelligence Agency.
     
    
    

    external by arashdn modified Aug 17, 2015  831  3  3  0

    VMWare vSphere List VM's with PHP using webservices

    VMWare vSphere List VM's with PHP using webservices: vmware-vsphere-list-vm.php
    <?php
    class soapclientd extends soapclient
    {
    	public $action = false;
    
        public function __construct($wsdl, $options = array())
    	{
            parent::__construct($wsdl, $options);
        }
    
    	public function __doRequest($request, $location, $action, $version, $one_way = 0)
    	{
    //        echo '<pre>' . htmlspecialchars(str_replace(array ('<ns', '></'), array (PHP_EOL . '<ns', '>'.PHP_EOL.'</'), $request)) . '</pre>';
            $resp = parent::__doRequest($request, $location, $action, $version, $one_way);
    		return $resp;
    	}
    
    }
    
    $client = new soapclientd('vimService.wsdl', array ('location' => 'http://10.1.0.47/sdk', 'trace' => 1));
    
    try
    {
        $request = new stdClass();
        $request->_this = array ('_' => 'ServiceInstance', 'type' => 'ServiceInstance');
        $response = $client->__soapCall('RetrieveServiceContent', array((array)$request));
    } catch (Exception $e)
    {
        echo $e->getMessage();
        exit;
    }
    $ret = $response->returnval;
    
    try
    {
        $request = new stdClass();
        $request->_this = $ret->sessionManager;
        $request->userName = 'root';
        $request->password = 'abc123456';
        $response = $client->__soapCall('Login', array((array)$request));
    } catch (Exception $e)
    {
        echo $e->getMessage();
        exit;
    }
    
    $ss1 = new soapvar(array ('name' => 'FolderTraversalSpec'), SOAP_ENC_OBJECT, null, null, 'selectSet', null);
    $ss2 = new soapvar(array ('name' => 'DataCenterVMTraversalSpec'), SOAP_ENC_OBJECT, null, null, 'selectSet', null);
    $a = array ('name' => 'FolderTraversalSpec', 'type' => 'Folder', 'path' => 'childEntity', 'skip' => false, $ss1, $ss2);
    
    $ss = new soapvar(array ('name' => 'FolderTraversalSpec'), SOAP_ENC_OBJECT, null, null, 'selectSet', null);
    $b = array ('name' => 'DataCenterVMTraversalSpec', 'type' => 'Datacenter', 'path' => 'vmFolder', 'skip' => false, $ss);
    
    $res = null;
    try
    {
        $request = new stdClass();
        $request->_this = $ret->propertyCollector;
        $request->specSet = array (
            'propSet' => array (
                array ('type' => 'VirtualMachine', 'all' => 0, 'pathSet' => array ('name', 'guest.ipAddress', 'guest.guestState', 'runtime.powerState', 'config.hardware.numCPU', 'config.hardware.memoryMB')),
            ),
            'objectSet' => array (
                'obj' => $ret->rootFolder,
                'skip' => false,
                'selectSet' => array (
                    new soapvar($a, SOAP_ENC_OBJECT, 'TraversalSpec'),
                    new soapvar($b, SOAP_ENC_OBJECT, 'TraversalSpec'),
                    ),
                )
            );
        $res = $client->__soapCall('RetrieveProperties', array((array)$request));
    } catch (Exception $e)
    {
        echo $e->getMessage();
    }
    echo '<pre>';
    print_r($res);
    
    
    

    external by yannvery modified Dec 27, 2013  459  0  3  0

    Savon Client for SDM webservices

    Savon Client for SDM webservices: client.rb
    require 'savon'
    client = Savon.client(wsdl: "http://par1db1-21:8080/axis/services/USD_R11_WebService?wsdl")
    
    #List all operations
    #client.operations
    
    #login
    response = client.call(:login, message: {username: "zumery", password: "Angele%1213"})
    sid = response.body[:login_response][:login_return]
    
    #update object sumary
    response = client.call(:update_object, message: {sid: sid, objectHandle: "cr:581141", "attributes" => ["summary"], "attrVals" => ["test"]})
    
    
    

    external by agharris73 modified Aug 22, 2014  208  1  3  0

    WebServices PrePaidBalanceSwipe with Token

    WebServices PrePaidBalanceSwipe with Token: gistfile1.txt
    public class TOKEN
        {
            // Transaction Varialbles
            private static string merchantID = "023358150511666";
            private static string password = "xyz";
            private static string invoiceNo = string.Empty;
            private static string memo = "Testing: WebServices.CSharp";
            private static decimal purchase = 2.25m;
            private static string operatorID = "test";
           
            // Gift Test Card
            private static string swipedGiftTrack2 = "6050110010021825160=250110115";
            private static string keyedGiftAcctNo = "6050110010021825160";
            private static string keyedGiftExpDate = "0125";
    
            public void Run()
            {
                PrePaidBalanceSwiped();
    
                Console.Write("End of samples");
                Console.ReadLine();
            }
            
            private static void PrePaidBalanceSwiped()
            {
                Console.Write("Hit Enter to run PrePaid Balance (Swiped)");
                Console.ReadLine();
    
                invoiceNo = NewInvoiceNo();
    
                // Create Request KeyValuePairs
                Dictionary<string, object> requestDictionary = new Dictionary<string, object>();
                requestDictionary.Add("MerchantID", merchantID);
                requestDictionary.Add("IpPort", "9100");
                requestDictionary.Add("TranType", "PrePaid");
                requestDictionary.Add("TranCode", "Balance");
                requestDictionary.Add("InvoiceNo", invoiceNo);
                requestDictionary.Add("RefNo", invoiceNo);
                requestDictionary.Add("Memo", memo);
                requestDictionary.Add("Track2", swipedGiftTrack2);
                requestDictionary.Add("OperatorID", operatorID);
    
                // Process Transaction and get Response KeyValuePairs           
                Dictionary<string, string> responseDictionary = ProcessGiftTransaction(requestDictionary, password);
    
                DisplayResponseKeyValuePairs(responseDictionary, "PrePaid", "Balance");
            }
            
            private static string NewInvoiceNo()
            {
                return DateTime.Now.ToString("yyMMddhhmmssfff");
            }
    
            private static Dictionary<string, string> ProcessGiftTransaction(Dictionary<string, object> requestDictionary, string password)
            {
                // Build XML Request from KeyValuePairs
                string xmlRequest = XMLHelper.BuildXMLRequest(requestDictionary).ToString();
                string xmlResponse = string.Empty;
    
                using (MercuryWebServices.wsSoapClient client = new MercuryWebServices.wsSoapClient())
                {
                    Console.WriteLine("Processing Gift Transaction...");
                    xmlResponse = client.GiftTransaction(xmlRequest, password);
                }
    
                // Parse XML Response into KeyValuePairs
                return XMLHelper.ParseXMLResponse(xmlResponse);
            }
    
            private static void DisplayResponseKeyValuePairs(Dictionary<string, string> responseDictionary, string tranType, string tranCode)
            {
                Console.WriteLine();
                Console.WriteLine(string.Format("--- Response Key Value Pairs for {0} {1} ---", tranType, tranCode));
    
                foreach (KeyValuePair<string, string> kvp in responseDictionary)
                {
                    Console.WriteLine(string.Format("{0}:{1};", kvp.Key, kvp.Value));
                }
    
                Console.WriteLine();
                Console.WriteLine();
            }
    
    
    • Public Snippets
    • Channels Snippets