Skip navigation.

Developer's Guide for Parlay X

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents View as PDF  
Get
Adobe Reader

Parlay X Examples

The following sections describe the Parlay X Web Service examples:

 


About the examples

Below are a set of examples given that illustrates how to use of the Parlay X Web Web services using AXIS and Java.

 


Send SMS

Get hold of the Send SMS Web Service.

Listing 4-1 Get hold of the SMS Service

SendSmsService sendSmsService = new SendSmsServiceLocator();
java.net.URL endpoint = new java.net.URL(sendSmsWsdlUrl);
SendSmsPort sendSms = sendSmsService.getSendSmsPort(endpoint);

The security header is created as outlined in Listing 3-2 and the header is added to the port. The destination address parameter is defined, and the method is invoked. The second parameter of the sendSms method is a combination of the mailbox ID as given by the service provider, the corresponding password and the originator address. The format is "<mailboxID>\<mailboxPassword>\<originator>", for example "tel:50001\thepassword\tel:+46547600". The third parameter is operator-specific, it is used for charging purposes. The message is an ordinary String. An ID is returned. This ID can be used to retrieve delivery status information for the SMS.

Listing 4-2 Add the security header and send the SMS

header.setMustUnderstand(true);
((org.apache.axis.client.Stub)sendSms).setHeader(header);
EndUserIdentifier[] eui = new EndUserIdentifier[1];
eui[0] = new EndUserIdentifier();
eui[0].setValue(new org.apache.axis.types.URI("tel:" + destAddress));
String sendID = sendSms.sendSms(eui, myMailbox, "CP_FREE", myMessage );

Below is outlined how the ID is used to get hold of delivery status information.

Listing 4-3 Get delivery status

DeliveryStatusType[] status = sendSms.getSmsDeliveryStatus(sendID);
System.out.println("Delivery status:" +status[0].getDeliveryStatus().toString());

 


SMS Notifications

SMS notifications are sent asynchronously from the WebLogic Network Gatekeeper. This means that the application must implement a Web Service. The initial thing is to start the Web Service server and deploy the implementation of the Web service into the server. The deployment is made using a deployment descriptor that is automatically generated when the Web Service java skeletons are generated.

Listing 4-4 Start SimpleAxis server

 // start SimpleAxisServer
org.apache.axis.transport.http.SimpleAxisServerserver = 
new org.apache.axis.transport.http.SimpleAxisServer();
System.out.println("Opening server on port: "+ port);
ServerSocket ss = new ServerSocket(port);
server.setServerSocket(ss);
server.start();
System.out.println("Starting server...");
// Read the deployment description of the service
InputStream is = new FileInputStrem(deploymenDescriptorFileName);
// Now deploy our  web service
org.apache.axis.client.AdminClient adminClient;
adminClient = new org.apache.axis.client.AdminClient();
System.out.println("Deploying receiver server web service...");
adminClient.process(new org.apache.axis.utils.Options(new String[] {"-ddd","-tlocal"}), deploymentDescriptorStream);
System.out.println("Server started. Waiting for connections on: " + port); 

The deployment descriptor (deploy.wsdd) was modified to refer to the class that implements the Web Service interface. This class is outlined in Listing 4-5. The class is based on the auto-generated file SmsNotificationBindingImpl.java.

Listing 4-5 Implementation of the smsNotification Web Service

public class SmsNotification implements org.csapi.www.wsdl.parlayx.sms.v1_0.notification.SmsNotificationPort{
public void notifySmsReception(String registrationIdentifier,
                               String smsServiceActivationNumber,
                               EndUserIdentifier senderAddress,
                                 String message)
   throws java.rmi.RemoteException, ApplicationException {
   System.out.println("->New SMS arrived");
   System.out.println("  Registration Indentifier " + 
                           registrationIdentifier );
   System.out.println("  Service activation number " +
                           smsServiceActivationNumber );
   System.out.println("  Sender adress " + senderAddress.getValue() );
   System.out.println("  Message " + message );
   }
}

 


Send MMS

First is a handle to the send MMS service retrieved.

Listing 4-6 Get hold of the Send MMS service

SendMessageServiceLocator sendMmsService = new SendMessageServiceLocator();
java.net.URL endpoint = new java.net.URL(sendMmsWsdlUrl);
SendMessagePort sendMms = sendMmsService.getSendMessagePort(endpoint); 

The security header is created as outlined in Listing 3-2 and the header is added to the port.

Listing 4-7 Add security header

((org.apache.axis.client.Stub)sendMms).setHeader(header);

The contents of the MMS are sent as SOAP attachment in MIME format, consisting of several attachment parts. The method defineattAchmentPart described in Listing 4-18. Each attachment part is added to the header of the object representing the call.

Listing 4-8 Creating two attachment parts.

int index = 1;
AttachmentPart ap = new AttachmentPart();
ap = defineAttachmentPart("file:../img/afile.jpg",
                          "image/jpeg",
                          "afile",
                          index++);
((org.apache.axis.client.Stub)sendMms).addAttachment(ap);
ap = defineAttachmentPart("file:../img/anotherfile.jpg",
                          "image/jpeg",
                          "anotherfile",
                          index++);
((org.apache.axis.client.Stub)sendMms).addAttachment(ap);

When the attachment parts have been defined and added to the call object, the method sendMessage is invoked. The second parameter of the sendMessage method is a combination of the mailbox ID as given by the service provider, the corresponding password and the originator address. The format is "<mailboxID>\<mailboxPassword>\<originator>", for example "tel:50001\thepassword\tel:+46547600".

Listing 4-9 Send the MMS

EndUserIdentifier[] eui = new EndUserIdentifier[1];
eui[0] = new EndUserIdentifier();
eui[0].setValue(new org.apache.axis.types.URI("tel:" + destAddress));
String sendID = sendMms.sendMessage(eui, myMailbox, "A subject line",
                                      MessagePriority.Default,"CP_FREE");
System.out.println("Send ID:" + sendID);

The delivery status of the message can be retrieved as outlined in Listing 4-10.

Listing 4-10 Check the delivery status

DeliveryStatusType[] status = sendMms.getMmsDeliveryStatus(sendID);
System.out.println("Delivery status:"
                     +status[0].getDeliveryStatus().toString());

 


Poll for new MMSes

An application can poll for new messages. A list of references to the unread messages are returned. The messages are retrieved using these references.

Listing 4-11 Get hold of Receive Message service

receiveMmsService = new ReceiveMessageServiceLocator();
java.net.URL endpoint = new java.net.URL(ReceiveMmsWsdlUrl);
ReceiveMessagePort receiveMms =    receiveMmsService.getReceiveMessagePort(endpoint); 

The security header is created as outlined in Listing 3-2 and the header is added.

Listing 4-12 Add the security header

((org.apache.axis.client.Stub)receiveMms).setHeader(header);

In Listing 4-13, the mailbox is polled for new messages. A MessageRefIdentifier is retrieved for each new message. The first parameter in getRecievedMessages is specified as <mailboxID>\<mailboxpassword>, for example "tel:10000\thepassword". The mailboxID and the corresponding password is defined by the service provider.

For each new message, the MessageContext is retrieved. The MessageContext makes it possible to retrieve the response message, where the contents of the MMS is found. The MMS message is found in the SOAP header of the HTTP response of the request to getMessage. The number of attachments are retrieved and also the number of attachment parts. The method extractAttachment can be implemented as described in Listing 4-21.

Listing 4-13 Poll and receive new messages

String[] messageRef;
messageRef = receiveMms.getReceivedMessages(myMailbox,
                                               MessagePriority.Default);
if (messageRef.length != 0) {
   int i=0;
   // For each new message
   while(i< messageRef.length){
      System.out.println("Messageref: " + messageRef[i]);
      receiveMms.getMessage(messageRef[i].getMessageRefIdentifier());
      System.out.println("getMessage returned OK");
      // Get the context of the SOAP message
      MessageContext context;
      context = receiveMmsService.getCall().getMessageContext();
       // Get the last response message.
      org.apache.axis.Message reqMsg = context.getResponseMessage();
      // Get the SOAP attachmnents
      Attachments attachments = reqMsg.getAttachmentsImpl();
      System.out.println("Number of attachments: " +
      attachments.getAttachmentCount());
      // Get the actual SOAP attachmnent
      java.util.Collection c = attachments.getAttachments();
      extractAttachments(c);
      i++;
   }
   } else {
      System.out.println("No messages found in Mailbox " + myMailbox);
   }
}

 


Receive notifications about new MMSes

Notifications about new MMS are handled in the same manner as for notifications about new SMSes. See Listing , the wen service environment is started in the same way as outlined in Listing 4-4, and the deployment descriptor is read in the same manner. The deployment descriptor to use is auto generated from the WSDL file for Multimedia Message Notifications. The implementation of the interface is also based on the auto generated class MmNotificationBindingImpl. The adapted implementation of this class file is outlined in Listing 4-14.

Listing 4-14 Implementation of listener interface

public class MmsNotification implements MmNotificationPort{
public void notifyMessageReception(String registrationIdentifier,
                                   MessageRef messageRef)
throws java.rmi.RemoteException, ApplicationException {
   System.out.println("->New Message arrived");
   System.out.println("Registration Indentifier  " +
                        registrationIdentifier );
   System.out.println("  Message reference " + messageRef );
   GetMms aMessage = new GetMms();
   aMessage.get(messageRef);
   }
}

The parameter messageref can be used to fetch the actual MMS. In the example above this is performed using the class GetMMS. For simplicity this call is not threaded, which it should be in a live system.

 


Get an MMS by it's message reference ID

The message reference ID can be retrieved notifications from the WebLogic Network Gatekeeper, as outlined in Receive notifications about new MMSes.

The example below illustrates how to fetch the actual MMS.

A handle to the receive message web service is retrieved as outlined in Listing 4-11.

The security header is created as outlined in Listing 3-2 and the header is added to the port.

The getMessage method is invoked using the message reference ID as an inparameter, see Listing 4-15. This ID can be retrieved as outlined in Receive notifications about new MMSes.

Listing 4-15 Get Message

receiveMms.getMessage(messageRef.getMessageRefIdentifier());
System.out.println("getMessage returned OK");

The method returns void, and the contents of the MMS is returned as attachments in the SOAP header of the HTPP response. In Listing 4-16, the SOAP header and the attachments are retrieved.

Listing 4-16 Get the context of the SOAP message

MessageContext context = receiveMmsService.getCall().getMessageContext();
// Get the last response message.
org.apache.axis.Message reqMsg = context.getResponseMessage();
// Get the SOAP attachmnents
Attachments attachments = reqMsg.getAttachmentsImpl();
System.out.println("Number of attachments: " +
                     attachments.getAttachmentCount());

The different parts of the attachments are extracted as outlined in Listing 4-13.

 


Handling SOAP Attachments

When sending and receiving multimedia messages, the content is handled as attachments in MIME or DIME using SwA, SOAP with Attachments. This technique combines SOAP with MIME, allowing any arbitrary data to be included in a SOAP message.

An SwA message is identical with a normal SOAP message, but the header of the HTTP request contains a Content-Type tag of type "multipart/related", and the attachment block(s) after the termination tag of the SOAP envelope.

Axis and Java Mail classes can be used to construct and deconstruct MIME/DIME SwA messages.

Encoding a multipart SOAP attachment

Listing 4-17 gives an example on how to create an attachment and to add it to the SOAP header. Two attachment parts are created.

Listing 4-17 Create an attachment

SendMessageServiceLocator sendMmsService = new SendMessageServiceLocator();
java.net.URL endpoint = new java.net.URL(sendMmsWsdlUrl);
SendMessagePort sendMms = sendMmsService.getSendMessagePort(endpoint);
AttachmentPart ap = new AttachmentPart();
ap = defineAttachmentPart("file:../img/img1.jpg",
                            "image/jpeg",
                            "img1",
                              index++);
((org.apache.axis.client.Stub)sendMms).addAttachment(ap);
ap = defineAttachmentPart("file:../img/img2.jpg",
                          "image/jpeg",
                          "img2",
                            index++);
((org.apache.axis.client.Stub)sendMms).addAttachment(ap);

The method defineAttachmentPart is illustrated Listing 4-18. The method creates an attachment part. The method is invoked with the following parameters:

Listing 4-18 Define an attachment part

private AttachmentPart defineAttachmentPart(String mmsInfo,
                                            String contentType,
                                            String contentId,
                                               int index){
   AttachmentPart apPart = new AttachmentPart();
   try {
      URL fileurl = new URL(mmsInfo);
      BufferedInputStream bis = 
      new BufferedInputStream(fileurl.openStream());
      apPart.setContent( bis, contentType);
      apPart.setMimeHeader("Ordinal", String.valueOf(index));
      //reference the attachment by contentId.
      apPart.setContentId(contentId); 
   } catch (Exception ex) {
   ex.printStackTrace();
   }
   return apPart;
}

Retrieving and Decoding a multipart SOAP attachment

In order to get a SOAP attachment, the response message is necessary since the SOAP attachment is returned in as an attachment in the SOAP header of the HTTP response. In Listing 4-19, the response message is retrieved.

Listing 4-19 Get a response message

// Get the context of the SOAP message
MessageContext context = receiveMmsService.getCall().getMessageContext();
// Get the last response message.
org.apache.axis.Message reqMsg = context.getResponseMessage();

When a handle to the response message is retrieved, the SOAP attachments can be fetched.

Listing 4-20 Get the SOAP attachments

Attachments attachments = reqMsg.getAttachmentsImpl();
java.util.Collection c = attachments.getAttachments();

Each attachment, and each attachment part, is traversed and decoded. In the example the attachments are saved to file.

Listing 4-21 Extract the attachments

java.util.Collection c = attachments.getAttachments();
Iterator it = c.iterator();
// For each attachment
while( it.hasNext()){
   org.apache.axis.attachments.AttachmentPart p =
   (org.apache.axis.attachments.AttachmentPart)it.next();
   javax.activation.DataHandler dh= p.getDataHandler();
   BufferedInputStream bis = new BufferedInputStream(dh.getInputStream());
   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   while (bis.available() > 0) {
      bos.write(bis.read());
      }
   byte[] pmsg = bos.toByteArray();
   System.out.println("Message Length: "+pmsg.length); 
   System.out.println("Content Type: "+p.getContentType());
   System.out.println("Content ID: "+p.getContentId());
   // Convert mime identifier to file extension
   String type =
   p.getContentType().substring(1+p.getContentType().lastIndexOf("/",
   p.getContentType().length()));
   // Save attachment as file
   FileOutputStream fos = new FileOutputStream("ContentID_"
                                                    +p.getContentId()+
                                                   "."+ type);
   fos.write(pmsg);
   fos.close();
}

 


Setting up a two-party call from an application

A two party call can be set up an controlled from an application using the Parlay X Third Party Call API.

The mechanism is, simplified, as follows:

  1. The application orders the call to be set up between a calling party and a called party.
  2. The first call leg is set up between the calling party and the MSC or the local exchange.
  3. A call attempt is performed to the calling party. At this stage, no action has been performed towards the called party.
  4. When the calling party answers, a call attempt is performed to the called party.
  5. When the called party answers, the two call legs are connected and the call is processed.

Naturally this is the ideal situation. A number of other scenarios can be identified, where either the calling party or the called party:

Using the method cancelCallRequest, the request to setup the call can be cancelled. This method is valid until both parties have answered.

When the call has been set up, the status of the call can be monitored using the method getCallInformation. The call can also be ended by the application using the method endCall.

Below is an example of how to set up a call between two parties.

First, a handle to the Third Party Call service is retrieved.

Listing 4-22 Get hold of the Third Party Call service

ThirdPartyCallService thirdPartyCallService = 
   new ThirdPartyCallServiceLocator();
java.net.URL endpoint = new java.net.URL(thirdPartyCallWsdlUrl);
setupCall = thirdPartyCallService.getThirdPartyCallPort(endpoint);

The security header is created as outlined in Listing 3-2 and the header is added to the port.

Listing 4-23 Add security header

((org.apache.axis.client.Stub)setupCall).setHeader(header);

The addresses, in URI-format (tel:<telephone number>) of the calling and the called party are defined and the call is set up. An identifier of the call is returned.

The method makeACall returns before the actual call is setup.

Listing 4-24 Setup the call

String callingParty = "+46111111";
String calledParty = "+462222222";
EndUserIdentifier[] eui = new EndUserIdentifier[2];
eui[0] = new EndUserIdentifier();
eui[0].setValue(new org.apache.axis.types.URI("tel:" + callingParty));
eui[1] = new EndUserIdentifier();
eui[1].setValue(new org.apache.axis.types.URI("tel:" + calledParty));
 m_callID = m_setupCall.makeACall(eui[0], eui[1], "cp_FREE");

The status of the call can be retrieved in order to let the application survey the call processing. The status is one of the following

Listing 4-25 Retrieve the status of the call

CallInformationType status;
status = setupCall.getCallInformation(callID);
System.out.println("Call status: " + status.getCallStatus().toString());

When the call has terminated, information about the call can be retrieved as illustrated below.

Listing 4-26 Retrieve call information

System.out.println("Call Information" );
System.out.println("-start time (YYYY-MM-DD HH:MM:SS:MSMS) " + status.getStartTime().get(Calendar.YEAR) + "-" +
status.getStartTime().get(Calendar.MONTH) + "-" +
 status.getStartTime().get(Calendar.DAY_OF_MONTH) + " " +
status.getStartTime().get(Calendar.HOUR_OF_DAY) + ":" +
status.getStartTime().get(Calendar.MINUTE) +  ":" +
status.getStartTime().get(Calendar.SECOND) +  ":" +
status.getStartTime().get(Calendar.MILLISECOND)); 
System.out.println(" -Call duration (s): " +status.getDuration());
System.out.println(" -Call termination cause: " +status.getTerminationCause().toString());

 


Handling network-initiated calls

A call originating from the telecom network hand be controlled from an application using the Parlay X Network Initiated Third Party Call API.

The mechanism is, simplified, as follows:

  1. A call attempt is performed from a calling party to a called party.
  2. The application is notified about the call attempt.
  3. The application can:

Naturally this is the ideal situation. A number of other scenarios can be identified, where the called party:

It is also possible to route the calling party directly to the application, when he or she goes off-hook, even before a destination number is dialled.

In all above scenarios it is possible for the application to define an operator-specific charging parameter.

The be able to handle network-initiated calls from an application, the calls must be routed to the WebLogic Network Gatekeeper. This is normally done by provision data into an MSC or a local exchange.

Notifications on network-initiated calls are sent asynchronously from the WebLogic Network Gatekeeper. This means that the application must implement a Web Service. The initial task is to start the Web Service server and deploy the implementation of the Web service into the server. The deployment is made using a deployment descriptor that is automatically generated when the Web Service java skeletons are generated. See Listing 4-4, Start SimpleAxis server on page 3 for an example on how the application is deployed into the Simple Axis Server.

The deployment descriptor (deploy.wsdd) is modified to refer to the class that implements the Web Service interface. This class is outlined in Listing 4-27. The class is based on the auto-generated file NetworkInitiatedCallBindingImpl.java, examples of implementations of the different methods are given below.

Listing 4-27 Implementation of the NotifyNwInitCallHandler Web Service

public class HandleNwInitCall implements NetworkInitiatedCallPort{
   public Action handleCalledNumber(EndUserIdentifier callingParty,
                                       EndUserIdentifier calledParty)
      throws java.rmi.RemoteException, InvalidArgumentException,
              UnknownEndUserException, ApplicationException {
     // See example code for handleCalledNumber below.
   }
   public Action handleOffHook(EndUserIdentifier callingParty) 
     throws java.rmi.RemoteException, InvalidArgumentException,
             UnknownEndUserException, ApplicationException {
     // See example code for handleOffHook below.
   }
   public Action handleBusy(EndUserIdentifier callingParty,
                            EndUserIdentifier calledParty) throws
      java.rmi.RemoteException, InvalidArgumentException,
       UnknownEndUserException, ApplicationException {
     // See example code for handleBusy below.
   }
    public Action handleNotReachable(EndUserIdentifier callingParty,
                                        EndUserIdentifier calledParty)
      throws java.rmi.RemoteException, InvalidArgumentException,
              UnknownEndUserException, ApplicationException {
      // Handling of the scenario when the called party is busy.
   }
public Action handleNoAnswer(EndUserIdentifier callingParty,
                               EndUserIdentifier calledParty)
      throws java.rmi.RemoteException, InvalidArgumentException,
              UnknownEndUserException, ApplicationException {
   // Handling of the scenario when there is no answer from the called party.
   }

Below is an example of an implementation of the method handleCalledNumber. In the example, the action returned is defined to "Route" and the routing address is set to routeNumber. This means that when the application is triggered, the number dialled by the calling party always is replaced with 12345678. The charging parameter is also set.

Listing 4-28 Example on implementation of handleCalledNumber

public Action handleCalledNumber(EndUserIdentifier callingParty,
                                   EndUserIdentifier calledParty)
      throws java.rmi.RemoteException, InvalidArgumentException,
              UnknownEndUserException, ApplicationException {
   System.out.println("handleCalledNumber()");
   System.out.println("Calling Party: " + callingParty.getValue());
   System.out.println("Calling Party: " + calledParty.getValue());
   String routeNumber = "tel:12345678";
   String charging_Param = "Free";
   Action action = new Action();
   try {   
      EndUserIdentifier eui = new EndUserIdentifier();
      eui.setValue(new org.apache.axis.types.URI("tel:" + routeNumber));
      action.setActionToPerform(ActionValues.Route);
      action.setRoutingAddress(eui);
      action.setCharging(charging_Param);
   }
   catch (Throwable e){
      return null;
   }
   return action;
}

Below is an example of an implementation of the method handleOffHook. In the example, the action returned is defined to "Route" and the routing address is set to routeNumber. This means that when the calling party goes off hook, the application is triggered, and a call is setup to 12345678. The charging parameter is also set.

Listing 4-29 Example on implementation of handleOffHook

public Action handleOffHook(EndUserIdentifier callingParty)
   throws java.rmi.RemoteException, InvalidArgumentException,
           UnknownEndUserException, ApplicationException {
   System.out.println("handleOffHook()");
   System.out.println("Calling Party: " + callingParty.getValue());
   String routeNumber = "tel:12345678";
   String charging_Param = "Free";
   Action action = new Action();
   try {   
      EndUserIdentifier eui = new EndUserIdentifier();
      eui.setValue(new org.apache.axis.types.URI("tel:" + routeNumber));
      action.setActionToPerform(ActionValues.Route);
      action.setRoutingAddress(eui);
      action.setCharging(charging_Param);
   }
   catch (Throwable e){
      return null;
   }
   return action;
}

Below is an example of an implementation of the method handleBusy. In the example, the action returned is defined to "Continue" which transfers the control of the call to the underlying telecom network, which acts on the call as any other call. The charging parameter is also set.

Listing 4-30 Example on implementation of handleBusy

public Action handleBusy(EndUserIdentifier callingParty, 
                           EndUserIdentifier calledParty)
      throws java.rmi.RemoteException, InvalidArgumentException,
              UnknownEndUserException, ApplicationException {
   System.out.println("HandleBusy()");
   System.out.println("Calling Party: " + callingParty.getValue());
   System.out.println("Called Party: " + calledParty.getValue());
   Action action = new Action();
   action.setActionToPerform(ActionValues.Continue);
   String charging_Param = "Free";
   action.setCharging(charging_Param);
   return action;
}

 


Get location

Get hold of the Terminal location Web Service.

Listing 4-31 Get hold of the Terminal Location

MobileTerminalLocationService mobileTerminalLocationService = new MobileTerminalLocationServiceLocator();
java.net.URL endpoint = new java.net.URL(mobileTerminalLocationWsdlUrl);
terminalLocation =
mobileTerminalLocationService.getMobileTerminalLocationPort(endpoint);

The security header is created as outlined in Listing 3-2 and the header is added to the port.

Listing 4-32 Add the security header

header.setMustUnderstand(true);
((org.apache.axis.client.Stub)terminalLocation).setHeader(header);

In Listing 4-33, the addresses of the requesting party and the requested party are defined, both in URI-format. The desired accuracy is defined and the method is invoked. An object of type LocationInfo is returned.

Listing 4-33 Define parameters and get the location

EndUserIdentifier requested = new EndUserIdentifier();
requested.setValue(new org.apache.axis.types.URI("tel:" +
                                                     requestedParty));
EndUserIdentifier requester = new EndUserIdentifier();
requester.setValue(new org.apache.axis.types.URI("tel:" +
                                                     requesterParty));
LocationAccuracy accuracy = LocationAccuracy.Medium;
locationInfo = terminalLocation.getLocation(requested, requester,
                                               accuracy);

The object holding the returned positioning information is used as outlined in Listing 4-34.

Listing 4-34 Retrieve the coordinates

System.out.println("Longitude: " + locationInfo.getLongitude() ); 
System.out.println("Latitude: " + locationInfo.getLatitude() ); 
System.out.println("Accuracy:" + locationInfo.getAccuracy().toString() ); 
java.text.SimpleDateFormat dateFormat = 
new java.text.SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
java.util.Date theTime = new
java.util.Date(locationInfo.getDateTime().getTimeInMillis());
System.out.println("Location data updated at: " +
dateFormat.format(theTime));

 


Get user status

Get hold of the User status Web Service.

Listing 4-35 Get hold of the User status web service

UserStatusService userStatusService = new UserStatusServiceLocator();
java.net.URL endpoint = new java.net.URL(userStatusWsdlUrl);
userStatus  = userStatusService.getUserStatusPort(endpoint);

The security header is created as outlined in Listing 3-2 and the header is added to the port.

Listing 4-36 Add the security header

header.setMustUnderstand(true);
((org.apache.axis.client.Stub)userStatus).setHeader(header);

In Listing 4-37, the addresses of the requesting party and the requested party are defined, both in URI-format. An object of type UserStatusData is returned.

Listing 4-37 Define parameters and get the status

EndUserIdentifier requested = new EndUserIdentifier();
requested.setValue(new org.apache.axis.types.URI("tel:" +
                                                     requestedParty));
EndUserIdentifier requester = new EndUserIdentifier();
requester.setValue(new org.apache.axis.types.URI("tel:" +
                                                     requesterParty));
System.out.println("Before getstatus");
UserStatusData userStatusData = userStatus.getUserStatus(requested,
                                                             requester);

The object holding the returned status information is used as outlined in Listing 4-38. If supported by the network, additional status data is provided

Listing 4-38 Retrieve the status

System.out.println("Status of the terminal is: " +
userStatusData.getUserStatusIndicator().toString());
System.out.println("Extended Status information :" +
userStatusData.getAdditionalUserStatusInformation());

 


Reserve and charge an account

Get hold of the Reserve Amount Charging Web Service, in order to make reservations and charge the reservation.

Listing 4-39 Get hold of the Reserve Amount Charging web service

ReserveAmountChargingService reserveAmountChargingService = new ReserveAmountChargingServiceLocator();
java.net.URL endpoint = new java.net.URL(reserveAmountChargingWsdlUrl);
reserveAmountCharging =
reserveAmountChargingService.getReserveAmountChargingPort(endpoint);

The security header is created as outlined in Listing 3-2 and the header is added to the port.

Listing 4-40 Add the security header

header.setMustUnderstand(true);
((org.apache.axis.client.Stub)reserveAmountCharging).setHeader(header);

Get hold of the Amount Charging Web Service, in order to directly charge an account.

Listing 4-41 Get hold of the Amount Charging web service

AmountChargingService amountChargingService = new AmountChargingServiceLocator();
java.net.URL endpoint = new java.net.URL(amountChargingWsdlUrl);
amountCharging = amountChargingService.getAmountChargingPort(endpoint);

The security header is created as outlined in Listing 3-2 and the header is added to the port.

Listing 4-42 Add the security header

header.setMustUnderstand(true);
((org.apache.axis.client.Stub)amountCharging).setHeader(header);

In Listing 4-43, the addresses of the party to charge is defined, in URI-format. The amount to reserve (amount1) is defined and the reservation is performed. A reservation ID is returned. This ID is used to identify the charging session in the subsequent reservations via calls to reserveAdditionalAmount. Finally the reservation is charged (it may also be released).

Listing 4-43 Make reservations and charge the reservation

EndUserIdentifier partyToCharge = new EndUserIdentifier();
partyToCharge.setValue(new org.apache.axis.types.URI("tel:" + endUser));
java.math.BigDecimal amount1 = new java.math.BigDecimal(10.1);
String billingText ="Initial reservation";
String reservationID = 
reserveAmountCharging.reserveAmount(partyToCharge,
                                    amount1,
                                       billingText);
java.math.BigDecimal amount2 = new java.math.BigDecimal(7);
billingText ="Additional reservation";
reserveAmountCharging.reserveAdditionalAmount(reservationID,
                                              amount2,
                                                 billingText);
java.math.BigDecimal amount = new java.math.BigDecimal(0);
amount.add(amount1);
amount.add(amount2);
billingText ="Charging the reservation";
java.lang.String referenceCode = "Unique referenceCode";
reserveAmountCharging.chargeReservation(reservationID, amount,
                                           billingText, referenceCode);

As an alternative an amount can be charged directly without any prior reservations as outlined in Listing 4-44.

Listing 4-44 Directly charge an account

amount = new java.math.BigDecimal(10.1);
billingText ="Direct debit";
referenceCode = "Unique referenceCode";
amountCharging.chargeAmount(partyToCharge, amount, billingText,
                              referenceCode);

 

Skip navigation bar  Back to Top Previous Next