A basic description of the service implementation is as follows,

  • The name of the service is XSDExampleAPI, this class extends the WsiServiceBaseAPI

  • The service methods use the following two types that are defined in the XSDExample.xsd provided for input and output parameters

    • InputParameter

    • OutputParameter

  • There are 4 service methods exposed within the service implementation, they are

    • exampleWsiService: This service method takes in an instance of type InputParameter, that is an XSD based GOSU class,   as input parameter and returns an instance of type OutputParameter, yet another XSD based GOSU class, as the response to the service call.

    • exampleWsiServiceArrayInput: This service method takes in an array of instances of type InputParameter, that is an XSD based GOSU class,   as input parameter and returns an instance of type OutputParameter, yet another XSD based GOSU class, as the response to the service call.

    • exampleWsiServiceArrayOutput: This service method takes in an instance of type InputParameter, that is an XSD based  GOSU class,   as input parameter and returns an array of instances of type OutputParameter, yet another XSD based GOSU class,as the response to the service call.

    • exampleWsiServiceArrayInputArrayOutput: This service method takes in an array of instances of type InputParameter, that is an XSD based GOSU class,   as input parameter and returns an array of instances of type OutputParameter, yet another XSD based GOSU class, as the response to the service call.

  • The name of the logger is based on the name passed in to the constructor “XSDExampleAPI” and is defined by the logger category “Integration.XSDExampleAPI”. The behavior of the logger is defined and controlled in logging.properties file.

Using XSD Code Sample1 lets take a look at the service method exampleWsiService and break down it’s implementation. The method invokes wsiExecute base class method (note that this method invokes the wsiExecute instead of  wsiExecuteAndReturnArray as this method returns a single instance of the OutputParameter entity). There are two parameters to this method

  • An anonymous GOSU block is passed as the first parameter. This GOSU block receives as input the input parameter passed into the service method and calls the processExampleWsiService method that ultimately provides the implementation of the business functionality. This anonymous GOSU block will be invoked by the base WsiServiceBaseAPI class.

  • The second parameter is the input ‘pInput’ to the service method itself that is in turn passed to the block by the WsiServiceBaseAPI class when the block in invoked.

  • The process processExampleWsiService implements the business specific logic – this example simply populates the response object. In a real life scenario the business functionality will be implemented here.

XSD Code Sample2 shows the service method exampleWsiServiceArrayInputArrayOutput that now takes in an array and returns an array. The method invokes wsiExecuteAndReturnArray base class method now since we are meaning to return multiple instances as opposed to a single instance above. There are two parameters to the wsiExecuteAndReturnArray as well

  • An anonymous GOSU block is passed as the first parameter. This GOSU block receives as array input the input parameter passed into the service method and calls the processExampleWsiServiceArrayInputArrayOutput method that ultimately provides the implementation of the business functionality. This anonymous GOSU block will be invoked by the base WsiServiceBaseAPI class.

  • The second parameter is the array input ‘pInput’ to the service method itself that is in turn passed to the block by the WsiServiceBaseAPI class when the block in invoked.

  • The process processExampleWsiServiceArrayInputArrayOutput implements the business specific logic – this example simply populates the response object. In a real life scenario the business functionality will be implemented here.

Sample Log File Output

The following sample log information for a single service call as logged in the server is provided, by default

  • In DEBUG logging mode there are two debug statements that log the input before processing and the output after processing

  • In INFO logging mode there is an info statement that logs the time taken, in milliseconds, to process the service and the status of the service (if an exception was thrown by the service implementation).

[java]                 2013-01-01 12:02:36,858 DEBUG WsiServiceBaseAPI[XSDExampleAPI]]:internalWsiExecute() – Processing – [<?xml version=”1.0??>
[java] <exam:InputParameter xmlns:exam=”http://atsynthesize.com/wsi/xsd/example” xmlns:soap=”http://www.w3.org/2003/05/soap-envelope” xmlns:soap1=”http://guidewire.com/ws/soapheaders” xmlns:xsd=”http://atsynthesize.com/gw/ws/atsynthesize/integration/service/example/xsd/XSDExampleAPI”>
[java]   <exam:input1>1</exam:input1>
[java]   <exam:input2>2</exam:input2>
[java]   <exam:input3>3</exam:input3>
[java] </exam:InputParameter>]

[java]                 2013-01-01 12:02:36,864 DEBUG WsiServiceBaseAPI[XSDExampleAPI]]:internalWsiExecute() – Processed – [<?xml version=”1.0??>
[java] <OutputParameter xmlns=”http://atsynthesize.com/wsi/xsd/example”>
[java]   <output1>InputVal1 – 1</output1>
[java]   <output2>InputVal2 – 2</output2>
[java]   <output3>InputVal3 – 3</output3>
[java] </OutputParameter>]

[java]                 2013–01–01 12:02:36,864 INFO WsiServiceBaseAPI[XSDExampleAPI]]:internalExecute() – Time:[28] Processed Service – Success:[true] – [atsynthesize.suite.integration.service.example.xsd.xsdexample.InputParameter instance]

SOURCE CODE: All the source code discussed within this blog is provided @ GitHub – Codebase. You are free to download, extend and send me comments on how you used it. If you want the extensions/changes to be incorporated into the code for others to use or alternatively would like to be part of the group that updates this GitHub project repository, send me a request and I will certainly get back to you. [Link: https://github.com/harikanangi/custom-gosu]

Share
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...


Posted by Hari Kanangi

Leave a reply