Archive

Author Archive

SWS GetInsuranceBrokerData Method

December 8, 2011 3 comments

Returns all of the insurance data on an insurance broker for the specified site and date. This method requires that the user has access to the insurance tables through special permissions; otherwise, an error is returned.

Parameters

Name DataType Is Required
InsBrokerOrgID Long Required
Description The organization’s ID number.
LocationSiteID Long Required
Description The site ID for the site from which the insurance company wishes to pull data.
SnapshotDate DateTime Required
Description The date to generate a snapshot of the insurance data. If today, only the data up to the current time will be returned.

Returned Parameters

Name DataType
InsuranceData String
Description An XML string of insurance broker data that can be read into a .Net DataSet or parsed using an XML parser. Note: Any return parameter that does not have a value will not be displayed in the XML generated.

Example

As with every method we need to pass in credentials. We do this with the LookupUser request object.

We will assume you have a web reference, let us name it SWS, in your Visual Studio project. At this point we need to define our objects.  We will need the standard service object, a GetInsuranceBrokerData request object, and a GetInsuranceBrokerData response object. We can define and create those like this:

// Create a request and response objects
SWS.WSSoapClient service = new SWS.WSSoapClient();
SWS.GetInsuranceBrokerData_Request request = new SWS.GetInsuranceBrokerData_Request();
SWS.GetInsuranceBrokerData_Response response;

Here is a sample code of the request object:

// GetInsuranceBrokerData Request
request.InsBrokerOrgID = 123456;
request.LocationSiteID = 123456;
request.SnapshotDate = DateTime.Today;

Finally we can call the method and pass across the login object and the request object to retrieve our requested information. It’s a good idea to do this in a Try Catch block.

‘ Call the method that will load the response object
try
{
  response = service.GetInsuranceBrokerData(user_request,request);
}
catch (Exception ex)
{
  MessageBox.Show(ex.Message);
}

Note that if something goes wrong the service will respond with an exception. You will want to capture the message in the exception so it can be debugged.

For a full list of methods see SWS Methods.

Categories: API General, Insurance

SOAP: Anatomy of Returned XML Document

June 20, 2011 Leave a comment

Every function call in SOAP will result in a XML document. The document will follow standard XML syntax and namespace conventions, and all requests and responses are data typed. A standard request and response is displayed below.

Request

    <?xml version="1.0" encoding="utf-8"?>
    <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
        <soap12:Body>
            <AddDeposit xmlns="http://www.centershift.com/STORE40/">
                <LookupUser_Request>
                    <Username>string</Username>
                    <Password>string</Password>
                    <Channel>int</Channel>
                </LookupUser_Request>
                <Request>
                    <RentalID>long</RentalID>
                    <DepositData>
                        <DEP_GROUP_ID>long</DEP_GROUP_ID>
                        <ORG_ID>long</ORG_ID>
                        <DEP_FIX>decimal</DEP_FIX>
                        <DEP_PERC>decimal</DEP_PERC>
                        <DEP_TYPE>int</DEP_TYPE>
                        <DEP_TYPE_VAL>string</DEP_TYPE_VAL>
                        <ACTIVE>boolean</ACTIVE>
                        <DEP_GROUP_NAME>string</DEP_GROUP_NAME>
                        <DEP_GROUP_DESC>string</DEP_GROUP_DESC>
                        <DEP_METHOD>int</DEP_METHOD>
                        <DEP_METHOD_VAL>string</DEP_METHOD_VAL>
                        <AMT_DESC>string</AMT_DESC>
                        <DEP_AMT>string</DEP_AMT>
                    </DepositData>
                </Request>
            </AddDeposit>
        </soap12:Body>
    </soap12:Envelope>

Response

    <?xml version="1.0" encoding="utf-8"?>
        <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
        <soap12:Body>
            <AddDepositResponse xmlns="http://www.centershift.com/STORE40/">
                <AddDepositResult>
                    <Succeeded>boolean</Succeeded>
                </AddDepositResult>
            </AddDepositResponse>
        </soap12:Body>
    </soap12:Envelope>
Categories: API General

.Net: Creating a Web Reference using Visual Studio 2008

June 20, 2011 Leave a comment

To use the Centershift STORE Web Service, you must create a Web Reference to it in Visual Studio.

1. Open a current project in Visual Studio, or create a new one.

2. Right click on the Service References node in the Solution Explorer Window, and click “Add Service Reference”. A form titled “Add Service Reference” will open.

3. Type in the following URL into the “Address” field at the top and click “Go”.

Development Links:
WCF: https://store.centershift.com/sandbox40/SWS.svc
SOAP: https://store.centershift.com/sandbox40/SWS.asmx
WSDL: https://store.centershift.com/sandbox40/SWS.svc?WSDL

Production Links:
WCF: https://store.centershift.com/Store40/SWS.svc
SOAP: https://store.centershift.com/Store40SWS.asmx
WSDL: https://store.centershift.com/Store40/SWS.svc?WSDL

4. Give the Web Service a namespace in the textbox labeled “Namespace”.

5. Click “OK”. The Web service is now available for consumption, and ready for the function calls described in this documentation.

You can now see all of the methods available through the STORE Web Services in the web references section of your Solution Explorer.

Using the STORE Web Services as Objects

You will still need a web reference in your project as described above. The following VB and C# code shows how to create objects and call a sample method:

Visual Basic Example (WCF):

     ‘++++USE THIS CODE IF YOU HAVE NOT SET A REFERENCE AT THE PROJECT LEVEL
‘Initialize the web service binding
Dim objBinding As New System.ServiceModel.BasicHttpBinding
objBinding.Security.Mode = ServiceModel.BasicHttpSecurityMode.Transport
objBinding.MaxReceivedMessageSize = Integer.MaxValue

     ‘Initialize the web service proxy using the binding and the given endpoint address
objService = System.ServiceModel.ChannelFactory(Of ServiceReference1.WS).CreateChannel(objBinding, New System.ServiceModel.EndpointAddress(“https://store.centershift.com/Sandbox40/SWS.svc “))
‘+++++

       ‘*****USE THIS CODE IF YOU SET A REFERENCE AT THE PROJECT LEVEL
Dim objService as New [Your Reference Name].WSSoapClient(“WSSoap”)
‘*****

       ‘ Create and set authentication credentials
Dim objLogin As New StoreWebServices.LookupUser_Request
With objLogin
.Username = “Username”
.Password = “Password”
.Channel = 999
End With

       ‘ Create the request object
Dim objReq As New StoreWebServices.UpdateRental_Request
‘ Set required parameters
With objReq
.RentalId = 123456
.MoveOutDate = “01/01/2010”
End With

‘ Create a response object
Dim objRes As New StoreWebServices.UpdateRental_Response

Try
‘ Call the method that will load the response object
objRes = objService.UpdateRental(objLogin, objReq)

‘ Bind your result data to object
Me.DataGridView1.DataSource = objRes.Details
Me.DataGridView1.Refresh()

Catch ex As Exception
MessageBox.Show(ex.Message)

End Try

C# Example (SOAP):

//Create the main Web Services object
SWS.WS ws = new SWS.WSClient();

//Create and set the authentication credentials
SWS.LookupUser_Request lookupUser = new SWS.LookupUser_Request();
lookupUser.Username = “Username”;
lookupUser.Password = “Password”;
lookupUser.Channel = 1;

//Create the method’s request object
SWS.GetPrimaryRentalInfo_Request request = new SWS.GetPrimaryRentalInfo_Request();

//Set required parameters
request.AccountID = 123;
request.SiteID = 1234;

//Create the method’s response object
SWS.GetPrimaryRentalInfo_Response response;

try
{
//Call the method and set its value to the response object
response = ws.GetPrimaryRentalInfo(lookupUser, request);

foreach (SWS.SOA_GET_PRIMARY_RENTAL_INFO thisres in response.Details)
{
MessageBox.Show(thisres.ACCT_NAME);
}
}
catch
{
//Error handling here.
}

The first step is to create a new WS object. This will correspond to the name that you specified when creating your web method.

//Create the main Web Services object
SWS.WS ws = new SWS.WSClient();

The basic concept is an object orientated approach of creating a request object, setting the parameters of this request, calling the method and loading the results into a response object. The response will usually be a collection of data that can be bound to display objects.

Each method call requires authentication and takes as parameter a login object which contains a username and password. You can create this object once and pass this into all methods you call.

//Create and set the authentication credentials
SWS.LookupUser_Request lookupUser = new SWS.LookupUser_Request();
lookupUser.Username = “Username”;
lookupUser.Password = “Password”;
lookupUser.Channel = 1;

You then create a request object and set any required parameters. The required parameters are specified for each method in this document. The method will also give you an error message if all required parameters are not set.

//Create the method’s request object
SWS.GetPrimaryRentalInfo_Request request = new SWS.GetPrimaryRentalInfo_Request();

//Set required parameters
request.AccountID = 123;
request.SiteID = 1234;

Now create the response object and call the desired method passing in this login object and the request object.

try
{
//Call the method and set its value to the response object
response = ws.GetPrimaryRentalInfo(lookupUser, request);

foreach (SWS.SOA_GET_PRIMARY_RENTAL_INFO thisres in response.Details)
{
MessageBox.Show(thisres.ACCT_NAME);
}
}
catch
{
//Error handling here.
}

Always use error handling to catch any problems with your method call. Each SWS method will throw specific error messages to help verify the correct data is passed in. For help with “unknown errors” please contact a SWS representative.

This is the basic methodology of all SWS methods. This Sample code is provided to show you how a SWS method should be called. Each method has the possibility of variations.

Categories: API General