Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
indent20px

Tipnote

It is also possible to write your own device using C# or Visual Basic. This is different than using the Custom Code device. If any of the following conditions apply to your organization, you may want to write your own device. If you do decide to write a device, it is recommended that you first use the Custom Code device to create the required logic, and then move that logic to your own device.

  • You are deploying Connexion outside of your infrastructure.
  • Connexion will be administered by third parties.
  • You require a user interface for device configuration/display.
  • You will be using the device logic in multiple channels.
  • Your code contains proprietary information.
  • You need advanced IDE features.

Add a Custom Code device in the same way you would add any other device. Stop the channel, open it for editing, and choose Custom Code Device from the drop-down.

Using the Custom Code window

...

The Custom Code device boiler-plate code provides the required CustomDevice class. It also provides three, empty, overridden methods:

  • Start: Called once when this device is started by the containing channel (channel started).
  • Stop: Called once when this device is stopped by the containing channel (channel stopped).
  • ProcessMessage: Called for every message received by this device. Your message logic should be in this method.

Using References

The Custom Code Device device allows the addition of local custom assemblies and .NET-framework assemblies. To add an assembly to your project, right click the References item and select Add Reference... A references window is opened showing a list of all assemblies registered in the GAC. You can either select a GAC-installed assembly from the list, or click the Browse button to point to a specific assembly file.

<screen shot>Image Added

The window contains the following:

  • Filter: Filter the GAC assemblies list.
  • Include: Check the checkbox check box beside the assembly you would like to include. Multiple assemblies can be selected before clicking OK.
  • Assembly Name: The GAC assembly name.
  • Version: The assembly version.

...

You can also use references to a remote service (usually a SOAP service) in your Custom Code device. Right click the Service Reference item and select Add Service Reference. The Add Service Reference window will be displayed.

...

  • Service address: the URL/URI of the service to connect to.
  • Parse Service button: click to connect to the service and query for methods and properties.
  • Service Information: displays the mthods and properties exposed by the given service.
  • Add Reference button: click to generate the service proxy class and add it to your project.

Using a Service Proxy

Unlike

...

service

...

proxies

...

created

...

in

...

Visual

...

Studio

...

(which

...

use

...

separate

...

definition

...

files),

...

you

...

must

...

explicitly

...

initialize

...

your

...

proxy

...

object

...

before

...

use.

...

For

...

example,

...

you

...

can

...

use

...

the

...

following

...

code

...

in

...

your

...

Start()

...

method

...

[Also

...

see

...

the

...

sample

...

templates

...

included

...

with

...

Connexion]:

//init the bing service. The values you use here should match the contents of the wsdl file for your service.
//Binding - choose a binding which is defined in the wsdl. You can set security in the binding.security classes.
BasicHttpBinding binding = new BasicHttpBinding();
//the uri of the web service.
EndpointAddress endpoint = new EndpointAddress("http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc");
var serviceFactory = new ChannelFactory<IGeocodeService>(binding, endpoint);
m_BingService = serviceFactory.CreateChannel();
if(m_BingService != null)
Logger.Debug("Successfully created proxy to Bing geocode service.");

...