WCF newbie


Hoping somebody would be willing to help me out with connecting to a WCF Service that I did not create.  I've tried working through a couple of examples on mSDN but couldn't make heads or tails of them.  I was asked to see if I could write something to connect to a Motorola premiere one software on a squad car MDC.  As a result I only have temporary access (as in a short, scheduled time frame) for development and I can't have a copy to take with me to play with.  I was given an API Manual from Motorola that allegedly has everything I need to talk through WCF to their application but since I've never seen WCF before I'm drowning in confusion here.  Best I can tell, I need to "talk" to the service as if it's a web site in the localhost using http protocols.

The manual says I can choose a by request or by subscription and I think I want Subscription since it would be easier for the end user but I'm not really sure?

I've included what I THINK is the necessary connection information, can anyone start me off with a code sample in VB.NET?  Please?

By Request: PremierOne Mobile client hosts WCF “Data Request Service” –
IMobileDataService. The hosted WCF service contract exposes Query and CAD Incident data to
third party applications. Figure 2-1 shows Third Party Vendor 1 application requesting query and
CAD incident data.
By Subscription: A third-party application registers and unregisters to PremierOne Mobile client
using the IMobileDataService service contract’s Register and UnRegister operation contracts.
PremierOne Mobile client updates all third party applications which implement the WCF service
contract - IDataReceiver – defined by PremierOne. In Figure 2-1 below, the Third Party Vendor 2
subscribes to PremierOne Mobile Client for subscribed CAD Incident data.

2.2.1 External System Registers to PremierOne Mobile Client
Service Contract IMobileDataService
Operation Contract Register
bool Register(RegisterParameters registerParam);
Description Third-party applications register to PremierOne Mobile client with a call
back address. As a result third party applications can now receive data
from PremierOne Mobile client.
Parameters See Table 2-15.
Return Values True if successful, otherwise false
Table 2-15 External System Registers to PremierOne Mobile Client Parameters
Name Type Description
registerParam RegisterParameters

public class RegisterParameters
    private string dataSource;
    private string careOfAddress;
    private string filter;
    private Credentials credentials;

Open in new window

a) dataSource (string ( nvarchar(50)) )
Type of data source that third-party applications want to subscribe. May be one
of the following data source:
E.g. : “Query”
E.g. : “Query, “Incident”
b) careOfAddress (string ( nvarchar(200)) )
The callback address of the WCF service hosted by 3rd party applications.
E.g. : "http://localhost:9501/ExternalTool/Simulator"
c) filter (text)
The filter condition for the third-party applications to subscribe to the specific
data within the data source type. To specify multiple filters use a comma for a
separator. For example, the third-party application can subscribe to both
“Active or Closed” incident data. Note: The Filter condition is only valid for data
source type – “Incident”.
E.g. : “Active,Update,Closed”
E.g. : “Active,Closed”
Active – Incident is in an Active status if it is assigned to a PremierOne User
and is being currently worked on.
Closed – Incident that is in a closed status and was previously worked by a
PremierOne user.
Update – Any updates (like comments, adding persons, Vehicles) that were
made to the incident.
d) The instance of Credentials that contains the authentication information of
the third-party application. For details, see “Credentials Class” on page A-1.

2.2.3 External System Implements IDataReceiver WCF Service
The third-party application subscribing to the PremierOne Mobile client data needs to implement
the IDataReceiver WCF service contract.
Service Contract IDataReceiver– The IDataReceiver interface is hosted by the external
application to receive data from the PremierOne mobile client.
Operation Contract ReceiveData
Method public void ReceiveData (string dataSource, string xmlResponse)
Description Third-party applications receive data from the PremierOne Mobile client.
The pre-requisite is that the third-party applications should register in
order to receive PremierOne Mobile client data. PremierOne Mobile
unregisters the third-party applications when it fails to send data to
those applications; third party applications should re-register themselves
to PremierOne Mobile.
Parameters See Table 2-17.
Return Values None
Table 2-17 External System Implements IDataReceiver WDR Service Parameters
Name Type Description
dataSource string Type of data source that third-party applications want to
subscribe. May be one of the following data sources:
• Query
• Incident
Table 2-18 XSD for Query xmlResponse
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://www.mot.com/pswgs/service/ExternalDataAgent" xmlns:xs="http://www.w3.org/
2001/XMLSchema" xmlns="http://www.mot.com/pswgs/service/ExternalDataAgent" xmlns:NS="http://www.mot.com/
pswgs/service/ExternalDataAgent" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!--xmlResponse definition-->
<xs:element name="QueryDataResponses">
<!-- Contains one or more records -->
<xs:element name="QueryDataResponses" type="QueryDataResponse" minOccurs="0" maxOccurs="unbounded" /
<xs:attribute name="Count" type="xs:int" /> <!--Indicate the count of Response-->

Open in new window


A.1 Credentials Class
public class Credentials
    private string externalUserName;
    private string externalPassword;
    private string premierOneUserId;

Open in new window

Any request to an API should be identified by a logged-on PremierOne Mobile User Id. Otherwise,
access to CAD incident and query data is denied.

Table A-1 Credentials Class Parameters
Parameter Name Description Data Type
externalUserName User Name of the third-party application string
externalPassword Password of the third-party application string
premierOneUserId Logged on PremierOne Mobile User Id string

A-2 July 2010
WCF Endpoints (Service and Client) Chapter A: Appendix A
You configure externalUserName and externalPassword using the PremierOne
Configuration Tool. Third-party applications should use these credentials to subscribe to
PremierOne Mobile client API data.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. .
A.2 WCF Endpoints (Service and Client)
WCF endpoint configuration is hosted by the PremierOne Mobile client.
Table A-2 WCF Endpoint Configuration
<?xml version="1.0" encoding="UTF-8"?>
         <service name="PSWGS.Mobile.Mdt.ExternalDataAgent.MobileDataService">
            <endpoint address="http://localhost:9500/ExternalDataAgent" binding="basicHttpBinding" bindingConfiguration="EDABindingConfiguration" contract="PSWGS.Mobile.Mdt.ExternalDataAgent.IMobileDataService" />
         <endpoint name="EDASendData" address="" binding="basicHttpBinding" bindingConfiguration="EDABindingConfiguration" contract="PSWGS.Mobile.Mdt.ExternalDataAgent.IDataReceiver" />
            <binding name="EDABindingConfiguration" receiveTimeout="00:30:00" sendTimeout="00:30:00" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
               July 2010 A-3
Client API Guide WCF Endpoints (Service and Client)
               <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="65535" />
      <add key="LogonUserId" value="NUser1" />

Open in new window

Who is Participating?
käµfm³d 👽Connect With a Mentor Commented:
That would depend on the service. As I mentioned before, you usually have what are called "proxy classes", and these classes basically serve as a physical representation of the service within your own code. Once everything has been created, you end up with a concrete class that you can instantiate. That class will have methods:  one for each service method that the WCF service exposes. Then it's simply a matter of calling instance methods in your own code--WCF takes care of the heavy lifting of creating the HTTP requests and returning the responses.
käµfm³d 👽Commented:
Were you given a WSDL file, or a URL where you can download the WSDL file?
zipnoticAuthor Commented:
No, just a PDF, it has a sizable appendix which may be the WSDL?  I can forward/ email the PDF?
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

zipnoticAuthor Commented:
A.2.1 Incident Data Request/Response Schema
Table A-4 Incident Data Request-Response Schema
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://www.mot.com/pswgs/service/ExternalDataAgent"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<!--xmlRequest definition-->
<xs:element name="IncidentSearchCriteria">
<xs:complexType >
<xs:sequence> <xs:element name="IncidentNumber" type="xs:string"/>
<!-- Or searches by time duration--> <xs:element name="CreateTimeSince"
<xs:element name="CreateTimeBy" type="xs:dateTime"/>
<!-- Or get the last response.--> <xs:element name="IncidentStatus"
<xs:element name="IncidentResponse">
<xs:sequence> <xs:element name="Incidents" type=Incident" minOccurs="0"
<xs:element name="Timestamp" type="xs:dateTime" />
<xs:complexType mixed="true" name="Incident">
<xs:element name="IncidentInfo" type="EdaIncidentInfo"/>
<xs:element name="IncidentLocation" type="EdaIncidentLocation"/>
<xs:element name="Vehicles" type="EdaIncidentVehicle" minOccurs="0"
<xs:element name="Suspects" type="EdaIncidentSuspect" minOccurs="0"
A-6 July 2010
WCF Endpoints (Service and Client) Chapter A: Appendix A
<xs:element name="Comments" type="EdaIncidentComment" minOccurs="0"
<xs:element name="Contractors" type="EdaIncidentContractor" minOccurs="0"
<xs:element name="Attachments" type="EdaIncidentAttachment" minOccurs="0"
<xs:element name="Histories" type="EdaIncidentHistory" minOccurs="0"
<xs:complexType name="IncidentInfo">
<xs:element name="IncidentNumber" type="xs:string"/>
<xs:element name="IncidentType" type="xs:string"/>
<xs:element name="ModifyingCircumstance" type="xs:string"/>
<xs:element name="IncidentStatus" type="xs:string"/>
<xs:element name="Priority" type="xs:string"/>
<xs:element name="Area" type="xs:string"/>
<xs:element name="Beat" type="xs:string"/>
<xs:element name="Sector" type="xs:string"/>
<xs:element name="CreateTime" type="xs:dateTime"/>
<xs:element name="PrimaryUnit" type="xs:string"/>
<xs:element name="BackUpUnits" type="xs:string" minOccurs="0"
<xs:element name="DispositionCodes" type="xs:string" minOccurs="0"
<xs:element name="IncidentReportNumbers" type="xs:string" minOccurs="0"
<xs:complexType name="IncidentLocation">
<xs:element name="Address" type="xs:string"/>
<xs:element name="LocationName" type="xs:string"/>
<xs:element name="LocationDescription" type="xs:string"/>
<xs:element name="BuildingNumber" type="xs:string"/>
<xs:element name="BuildingFloor" type="xs:string"/>
<xs:element name="ApartmentNumber" type="xs:string"/>
<xs:element name="City" type="xs:string"/>
Table A-4 Incident Data Request-Response Schema (Cont.)
July 2010 A-7
Client API Guide WCF Endpoints (Service and Client)
<xs:element name="State" type="xs:string"/>
<xs:element name="Latitude" type="xs:string"/>
<xs:element name="Longitude" type="xs:string"/>
<xs:element name="HighStr" type="xs:string"/>
<xs:element name="LowStr" type="xs:string"/>
<!--Street Address/Common Place/Intersection-->
<xs:element name= "Type" type="xs:string"/>
<xs:complexType name="IncidentSubject">
<xs:element name="Name" type="xs:string"/>
<xs:element name="Gender" type="xs:string"/>
<xs:element name="Race" type="xs:string"/>
<xs:element name="Height" type="xs:string"/>
<xs:element name="Weight" type="xs:string"/>
<xs:element name="Hair" type="xs:string"/>
<xs:element name="Eyes" type="xs:string"/>
<xs:element name="Birthday" type="xs:string"/>
<xs:element name="Age" type="xs:string"/>
<xs:element name="Build" type="xs:string"/>
<xs:element name="HasWeapon" type="xs:boolean"/>
<xs:element name="HasCause" type="xs:boolean"/>
<xs:element name="IsSearch" type="xs:boolean"/>
<xs:element name="IsPropertySeized" type="xs:boolean"/>
<xs:element name="SearchType" type="xs:string"/>
<xs:element name="LicenseNumber" type="xs:string"/>
<xs:element name="LicenseType" type="xs:string"/>
<xs:element name="LocaleId" type="xs:string"/>
<xs:element name="Phone" type="xs:string"/>
<xs:element name="ProbableCause" type="xs:string"/>
<xs:element name="StreetAddress" type="xs:string"/>
<xs:element name="City" type="xs:string"/>
<xs:element name="Building" type="xs:string"/>
<xs:element name="Apartment" type="xs:string"/>
<xs:element name="State" type="xs:string"/>
<xs:element name="MiscInfo" type="xs:string"/>
<xs:element name="Roles" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
Table A-4 Incident Data Request-Response Schema (Cont.)
A-8 July 2010
WCF Endpoints (Service and Client) Chapter A: Appendix A
<xs:complexType name="IncidentVehicle">
<xs:element name="License" type="xs:string"/>
<xs:element name="LicenseType" type="xs:string"/>
<xs:element name="State" type="xs:string"/>
<xs:element name="Vin" type="xs:string"/>
<xs:element name="Color" type="xs:string"/>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Registration" type="xs:string"/>
<xs:element name="LicenseYear" type="xs:string"/>
<xs:element name="Make" type="xs:string"/>
<xs:element name="Model" type="xs:string"/>
<xs:element name="Style" type="xs:string"/>
<xs:element name="ProbableCause" type="xs:string"/>
<xs:element name="IsSearch" type="xs:boolean"/>
<xs:element name="IsPropertySeized" type="xs:string"/>
<xs:element name="MiscInfo" type="xs:string"/>
<xs:element name="Roles" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:complexType name="IncidentComment">
<xs:element name="Content" type="xs:string"/>
<xs:element name="DeviceId" type="xs:string"/>
<xs:element name="UserId" type="xs:string"/>
<xs:element name="IsPriority" type="xs:boolean"/>
<xs:element name="DateTime" type="xs:dateTime" />
<xs:complexType name="IncidentContractor">
<xs:element name="SequenceNumber" type="xs:string"/>
<xs:element name="Contractor" type="xs:string"/>
<xs:element name="RequestStatus" type="xs:string"/>
Table A-4 Incident Data Request-Response Schema (Cont.)
July 2010 A-9
Client API Guide WCF Endpoints (Service and Client)
A.2.2 Incident Data Response XML Nodes Description
<xs:element name="ImpoundLocation" type="xs:string"/>
<xs:element name="Reason" type="xs:string"/>
<xs:element name="HeldStatus" type="xs:string"/>
<xs:element name="ActionCode" type="xs:string"/>
<xs:element name="Associations" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:complexType name="IncidentAttachment">
<xs:element name="Name" type="xs:string"/>
<xs:element name="Description" type="xs:string"/>
<xs:element name="FileSize" type="xs:int" />
<xs:element name="MINIBody" type="xs:byte" minOccurs="0" maxOccurs="unbounded"/>
<xs:complexType name="IncidentHistory">
<xs:element name="Transaction" type="xs:string"/>
<xs:element name="DeviceId" type="xs:string"/>
<xs:element name="UserId" type="xs:string"/>
<xs:element name="Data" type="NameValueType" minOccurs="0" maxOccurs="unbounded" />
käµfm³d 👽Commented:
A WSDL file, like the example in the link I provided, will start with <description> node. Using a WSDL file, you can quickly create a proxy class to interact with the service by means of the built-in tools withing Visual Studio. If you have to create it by hand, then it will be a bit more tedious.
zipnoticAuthor Commented:
Motorola rep said everything I needed was in this PDF (attached).  Guess I'd have to create manually.
käµfm³d 👽Commented:
Did they provide you with a URL for the service?
zipnoticAuthor Commented:
No. But I was hoping it was buried in the PDF somewhere.

I tought it would be this:

<endpoint name="MobileDataService" address="http://localhost:9500/ExternalDataAgent"
käµfm³d 👽Commented:
Well, that's what I was thinking too, but it certainly wouldn't be "localhost", hence my question. I was hoping that if you had the URL that Motorola may have enabled the functionality that exposes the WSDL (WCF comes with this out of the box until you turn it off).

You can build the classes you need from scratch, but it will take a lot longer to do. I'm afraid I've never hand-built the classes before, so I don't know immediately how to do it. We can try muddling through it if you like. I would strongly suggest asking Motorola for a WSDL, as hand-crafting the classes is likely to be error prone.
zipnoticAuthor Commented:
I'll try to make an inquiry to Motorola starting Monday.

Do you have a link or copy and paste type code as a simple example of how I need to send the XML or make a request?
zipnoticAuthor Commented:

OK, clearly I have no concept of what I'm doing.  The searches I've been doing haven't helped clarify things.  For now I'll close out this question until I can get the WSDL.

And just to double check, the WSDL isn't that long XML doc in the appendix of the PDF I attached right?

käµfm³d 👽Commented:
As best I can tell, the XML shown in the PDF are schemas that define what the requests and responses look like; they don't define the service itself. A WSDL would look like this:

From http://en.wikipedia.org/wiki/Web_Services_Description_Language
<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="http://www.w3.org/ns/wsdl" 
<!-- Abstract type -->
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
         <xs:element name="request"> ... </xs:element>
         <xs:element name="response"> ... </xs:element>
<!-- Abstract interfaces -->
   <interface name="Interface1">
      <fault name="Error1" element="tns:response"/>
      <operation name="Opp1" pattern="http://www.w3.org/ns/wsdl/in-out">
         <input messageLabel="In" element="tns:request"/>
         <output messageLabel="Out" element="tns:response"/>
<!-- Concrete Binding Over HTTP -->
   <binding name="HttpBinding" interface="tns:Interface1" 
      <operation ref="tns:Get" whttp:method="GET"/>
<!-- Concrete Binding with SOAP-->
   <binding name="SoapBinding" interface="tns:Interface1" 
      <operation ref="tns:Get" />
<!-- Web Service offering endpoints for both bindings-->
   <service name="Service1" interface="tns:Interface1">
      <endpoint name="HttpEndpoint" 
      <endpoint name="SoapEndpoint" 

Open in new window

zipnoticAuthor Commented:
OK, Thanks again for looking at this!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.