Upload
nancy-foster
View
213
Download
0
Tags:
Embed Size (px)
Citation preview
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
1
SSDG Connectors in
Java
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
2
SAP GenericApplication Specific
SPGeneric Application Specific
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
3
SAP Generic Connectors
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
4
Generic Synchronous API
makeSynchronousSubmitRequest() – making initial request to SSDG for
availing a service in synchronous mode
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
5
Asynchronous API
makeASynchronousSubmitRequest() - making initial request to SSDG for availing a service in asynchronous mode.makeSubmitPoll() - check the status of the request which has been submitted through asynchronous mode.makeListRequest() –get the status of all the requests submitted to SSDG during a specified time interval.makeDeleteRequest() - delete the request and response which have already been served successfully
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
6
Generic Responses
Success Status –Actual Response
Failed Status
Resubmit
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
7
Elements
Element Name : Classid
Data Type : String
Mandatory : YES (for all functions)
Description :Service ID of the service provided by SP.
URL of the service which is hosted on the Service Provider (SP).
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
8
Elements
Element Name :Transactionid
Data Type : String
Mandatory : NO (Depends on the SAP Application Specific Connector)
Description :Used by the SAP application to club multiple Submit Request into single transaction.
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
9
Elements
Element Name : Body
Data Type : Object
Mandatory : YES (for makeSynchronousSubmitRequest() , makeASynchronousSubmitRequest() )
Description : Payload for SP from SAP in the format understood by SP.
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
10
Elements
Element Name : correlationid
Data Type : String
Mandatory : YES (for functions makeSubmitPoll(), makeListRequest() ,makeDeleteRequest() )
Description : Unique identifier of the message. Used to make Submit Poll and Delete
Request. Used to correlate Submit Request & subsequent Submit Poll and Delete Request.
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
11
Elements
Element Name : responsemode
Data Type : Enum
Mandatory : YES (for all functions)
Description :Type of response requested by the originator.
ResponseMode.ASYNCHRONOUSResponseMode.SYNCHRONOUS
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
12
Elements
Element Name : nsdgtest
Data Type : Enum
Mandatory : YES(for all functions)
Description :Indicates whether a message submitted to the Gateway is a test message or a real message.
NSDGTest.NO –real message NSDGTest.YES-test message
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
13
Elements
Element Name :starttime
Data Type : Calendar
Mandatory : YES (for function makeListRequest())
Description :Present for making list request calls
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
14
Elements
Element Name : endtime
Data Type : Calendar
Mandatory : YES (for function makeListRequest())
Description :Present for making list request calls
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
15
Elements
Element Name : targetendpointurl
Data Type : String
Mandatory : YES (for all functions)
Description :URL of the Gateway
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
16
Elements
Element Name : SPauthentication
Data Type : Enum
Mandatory : YES (for all functions)Description : For end-to-end integrity of the
message to be verified by the SP, the body part of the message will be signed and the value included in the dsig:Signature element .
(for this AuthenticationType must be W3CSigned)
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
17
Elements
Element Name :AuthenticationType
Data Type : Enum
Mandatory : YES (for all functions)
Description : Indicates how the SAP will be authenticated to SP. Authentication Mode are of three types
Clear - AuthenticationType.CLEARSHA-1- AuthenticationType. ENCRYPTED W3C signed-
AuthenticationType.DIGITAL_SIGNATURE
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
18
Sequences
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
19
Synchronous Submit Request
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
20
Synchronous Submit Request from SAP
SAP (portal) Gateway SP( Back off )
makeSynchronousSubmitRequest()
SubmitRequest submitRequest=new SubmitRequest();
submitRequest.setTargetEndPointURL(targetEndPoint);
submitRequest.setTransactionId(transactionId);
submitRequest.setClassId(classId);
submitRequest.setResponseMode(ResponseMode.SYNCHRONOUS);
submitRequest.setNsdgTest(NSDGTest.NO);
submitRequest.setSpAuthentication(SPAuthentication.NO);
submitRequest.setAuthenticationType(AuthenticationType.CLEAR);
submitRequest.setMessageBody(xmlObject);
SubmitResponse submitResponse=new SubmitResponse();
SAPConnector connector = new SAPConnectorImpl();
submitResponse = connector.makeSynchronousSubmitRequest(submitRequest);
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
21
Synchronous Response for Synchronous submit request
Gateway SP Generic Connector
SP Application Specific Connector
callsyncSubmitRequest()
public Object callSyncSubmitRequest(Object body, String classid,
String transactionid, String correlationID) throws XmlException, RemoteException, IOException
{
System.out.println("In callSyncSubmitRequest of SP Application Specific");
System.out.println("Body ::::: "+body.toString());
//Process Request.
//SP Business Logic for Processing request comes here
//Prepare Response
XmlObject obj = XmlObject.Factory.parse(body.toString());
SPResponse response=new SPResponse();
//If no error set Response Type as RESPONSE.
response.setResponseType(ResponseType.RESPONSE);
response.setResponse(obj);
//Else if error Prepare Error object.
response.setResponseType(ResponseType.ERROR);
response.setResponse(obj);
return response;
}Sending Submit ResponseSending Submit Response
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
22
Submit Response
SAP (portal) Gateway
Synchronous Response
Status =SUCESS
if(submitResponse.getStatus().equalsRequestStatus.SUCCESS))
submitResponse.getResponse().toString());
Status =FAILED
if(submitResponse.getStatus().equals(RequestStatus.FAILED))
String error="";
String [] errors=submitResponse.getErrors();
for(int i=0;i<errors.length;i++)
{
System.out.println(errors[i]);
error=error+"\n"+errors[i];
}
Status = RESUBMIT
if(submitResponse.getStatus().equals(RequestStatus.RESUBMIT))
System.out.println("Please RESUBMIT the request. Reason :"+submitResponse.getReason());
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
23
Synchronous SUBMIT_REQUEST
SAP (portal) Gateway SP( Back off )
Synchronous Submit Request
Synchronous Response
Synchronous Response
Synchronous Submit Request
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
24
ASynchronous Submit Request
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
25
ASynchronous Submit RequestASynchronous Submit Request
SAP (portal) Gateway SP( Back off )
callAsyncSubmitRequest()makeASynchronousSubmitRequest()
SubmitRequest submitRequest=new SubmitRequest();
submitRequest.setTargetEndPointURL(targetEndPoint);
submitRequest.setTransactionId(transactionId);
submitRequest.setClassId(classId);
submitRequest.setResponseMode(ResponseMode.ASYNCHRONOUS);
submitRequest.setNsdgTest(NSDGTest.NO);
submitRequest.setSpAuthentication(SPAuthentication.NO);
submitRequest.setAuthenticationType(AuthenticationType.CLEAR);
submitRequest.setMessageBody(xmlObject);
SubmitResponse submitResponse=new SubmitResponse();
SAPConnector connector = new SAPConnectorImpl();
submitResponse = connector.makeASynchronousSubmitRequest(submitRequest);
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
26
Asynchronous Request from SAP Asynchronous Request from SAP
Gateway SP Generic Connector
SP Application Specific Connector
callAsyncSubmitRequest()
public Object callAsyncSubmitRequest(Object body, String classid,
String transactionid, String correlationID) throws XmlException, RemoteException, IOException
{
System.out.println("In callAsyncSubmitRequest of SP Application Specific");
System.out.println("Body ::::: "+body.toString());
//Process Request.
//SP Business Logic for Processing request comes here
SPResponse response=new SPResponse();
// If NO error set Response Type as ACKNOWLEDGEMENT.
response.setResponseType(ResponseType.ACKNOWLEDGEMENT);
// Else if error Prepare an Error object.
XmlObject error = XmlObject.Factory.parse(body.toString());
response.setResponseType(ResponseType.ERROR);
response.setResponse(error);
return response;
}
Submit Acknowledgement
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
27
Submit Acknowledgement
SAP (portal) Gateway
Submit Acknowledgement
//Retrieving the Status in SAP application specific Connector Code
Status =SUCESS
if(submitResponse.getStatus().equalsRequestStatus.SUCCESS))
String corrId= submitResponse.getCorrelationId();
String responseendpointurl=submitResponse. getResponseEndPointURL ();
Integer pollinterval=submitResponse. getPollInterval ();
//Retrieving the Status in SAP application specific Connector Code
Status =FAILED
if(submitResponse.getStatus().equals(RequestStatus.FAILED))
String error="";
String [] errors=submitResponse.getErrors();
for(int i=0;i<errors.length;i++)
{
System.out.println(errors[i]);
error=error+"\n"+errors[i];
}
//Retrieving the Status in SAP application specific Connector Code
Status = RESUBMIT
if(submitResponse.getStatus().equals(RequestStatus.RESUBMIT))
System.out.println("Please RESUBMIT the request. Reason :"+submitResponse.getReason());
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
28
Submit Poll
SAP (portal) Gateway SP( Back off )
Submit Poll
makeSubmitPoll()
SubmitPoll pollRequest=new SubmitPoll();
SubmitPollResponse pollResponse=new SubmitPollResponse();
pollRequest.setTargetEndPointURL(targetEndPoint);
pollRequest.setClassId(classId);
pollRequest.setTransactionId(transactionId);
pollRequest.setCorrelationId(correlationId);
pollRequest.setNsdgTest(NSDGTest.NO );
SAPConnector connector = new SAPConnectorImpl();
pollResponse = connector.makeSubmitPoll(pollRequest);
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
29
Submit Acknowledgement / Submit Acknowledgement / Submit Response send to SAP from SPSubmit Response send to SAP from SP
SAP (portal) Gateway SP( Back off )
Submit Response /Submit Acknowledgement
Submit Response /Submit Acknowledgement
Status =SUCESS
if(pollResponse.getStatus().equals(RequestStatus.SUCCESS)
{ //Check what is received - Response or ACKNOWLEDGEMENT.
if(pollResponse.getResponseDocumentType().equals(ResponseDocumentType.RESPONSE))
{
System.out.println("Response is received.");
System.out.println("RESPONSE DOCUMENT :"+pollResponse.getResponse().toString());
}
else
if(pollResponse.getResponseDocumentType().equals(ResponseDocumentType.ACKNOWLEDGEMENT))
{
System.out.println("Correlation ID : "+pollResponse.getCorrelationId());
System.out.println("Response End PointURL :+pollResponse.getResponseEndPointURL());
System.out.println("Poll Interval : "+pollResponse.getPollInterval()); }
}
Status =FAILED
if(pollResponse.getStatus().equals(RequestStatus.FAILED))
String error="";
String [] errors= pollResponse.getErrors();
for(int i=0;i<errors.length;i++)
{
System.out.println(errors[i]);
error=error+"\n"+errors[i];
}
Status = RESUBMIT
if(pollResponse.getStatus().equals(RequestStatus.RESUBMIT))
System.out.println("Please RESUBMIT the request. Reason :"+ pollResponse.getReason());
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
30
Asynchronous CommunicationAsynchronous Communication
SAP (portal) Gateway SP( Back off )
Asynchronous Submit Request
Submit poll
Submit ACKSubmit Response
Submit poll
RESPONSE
Asynchronous Submit Request
Submit ACK
Submit ACK
Submit ACK
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
31
Submit Response Component of SP
SP Generic Connector
SP Application Specific Connector
//Preparing Response in SP Application Specific Connector code
CommitResponse commitResponse=new CommitResponse();
commitResponse.setTargetEndPointURL("http://192.168.0.37:8080/gateway/services/NSDGService");
commitResponse.setTransactionId("123456789123456789123456789123");
commitResponse.setClassId("http://202.141.151.140/48");
commitResponse.setResponseType(ResponseType.RESPONSE);
commitResponse.setMessageBody(Payload from SP);
//Retrieving the status from SP Generic Connector
STATUS=SUCESS
if(returnResponse.getStatus().equals(RequestStatus.SUCCESS))
{
System.out.println("status :"+ returnResponse.getStatus());
System.out.println("correlationId :"+ returnResponse.getCorrelationId());
System.out.println("TransactionID :"+ returnResponse.getTransactionId());
System.out.println("AuditID :"+ returnResponse.getAuditId());
}
//Retrieving the status from SP Generic Connector
STATUS=RESUBMIT
if (returnResponse.getStatus().equals(RequestStatus.RESUBMIT))
{
System.out.println("status: "+returnResponse.getStatus());
System.out.println("Reason:"+returnResponse.getReason());
}
//Retrieving the status from SP Generic Connector
STATUS=FAILED
if (returnResponse.getStatus().equals(RequestStatus.FAILED))
{
System.out.println("i am end of exec"+ returnResponse.getStatus());
String[] erorResponse= returnResponse.getErrors();
for(int i=0;i<erorResponse.length;i++)
{
System.out.println("printing error :"+erorResponse[i] );
}
}
//Sending Response to SP Generic Connector
ReturnResponse returnResponse=remote.makeSubmitResponse(commitResponse);
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
32
List Request from SAP List Request from SAP (List Request for Submit Requests (List Request for Submit Requests
from SAP to SP)from SAP to SP)
SAP (portal) Gateway
List Response
makeListRequestforSubmitRequest()
ListRequest listRequest =new ListRequest();
listRequest.setTargetEndPointURL(targetEndPoint);
listRequest.setClassId(classId);
listRequest.setTransactionId(transactionId);
listRequest.setNsdgTest(NSDGTest.NO);
listRequest.setAuthenticationType(AuthenticationType.CLEAR);
listRequest.setStartTime(startTime);
listRequest.setEndTime(endTime);
ListResponse listResponse=new ListResponse();
SAPConnector connector = new SAPConnectorImpl();
listResponse = connector. makeListRequestForSubmitRequest(listRequest);
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
33
List Response
SAP (portal) Gateway
List Response
Status =SUCESS
if(listResponse.getStatus().equalsRequestStatus.SUCCESS))
{
System.out.println("LIST RESP DOC:"+listResponse.getResponse().toString());
}
Status =FAILED
if(listResponse.getStatus().equals(RequestStatus.FAILED))
String error="";
String [] errors=listResponse.getErrors();
for(int i=0;i<errors.length;i++)
{
System.out.println(errors[i]);
error=error+"\n"+errors[i];
}
Status = RESUBMIT
if(listResponse.getStatus().equals(RequestStatus.RESUBMIT))
{
System.out.println("Request failed. Please RESUBMIT.");
System.out.println(listResponse.getReason());
}
makeListRequestforSubmitRequest()
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
34
List Request
SAP (portal) Gateway
List Response
makeListRequestforSubmitResponse()
ListRequest listRequest =new ListRequest();
listRequest.setTargetEndPointURL(targetEndPoint);
listRequest.setClassId(classId);
listRequest.setTransactionId(transactionId);
listRequest.setNsdgTest(NSDGTest.NO);
listRequest.setAuthenticationType(AuthenticationType.CLEAR);
listRequest.setStartTime(startTime);
listRequest.setEndTime(endTime);
ListResponse listResponse=new ListResponse();
SAPConnector connector = new SAPConnectorImpl();
listResponse = connector. makeListRequestForSubmitResponse(listRequest);
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
35
List ResponseList Response
SAP (portal) Gateway
List Response
Status =SUCESS
if(listResponse.getStatus().equalsRequestStatus.SUCCESS))
{
System.out.println("LIST RESP DOC:"+listResponse.getResponse().toString());
}
Status =FAILED
if(listResponse.getStatus().equals(RequestStatus.FAILED))
String error="";
String [] errors=listResponse.getErrors();
for(int i=0;i<errors.length;i++)
{
System.out.println(errors[i]);
error=error+"\n"+errors[i];
}
Status = RESUBMIT
if(listResponse.getStatus().equals(RequestStatus.RESUBMIT))
{
System.out.println("Request failed. Please RESUBMIT.");
System.out.println(listResponse.getReason());
}
makeListRequestforSubmitResponse()
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
36
Delete Request
SAP (portal) Gateway
Delete Response/Delete Acknowledgement
makeDeleteReques()
DeleteResponse deleteResponse=new DeleteResponse();
DeleteRequest deleteRequest =new DeleteRequest();
String classId="http://192.168.0.140/130";
String transactionId="";
String correlationId="1DD174252C6648A38D6E6D410B5F43";
String targetEndPoint="http://192.168.0.37:8080/gateway/services/NSDGService";
deleteRequest.setTargetEndPointURL(targetEndPoint);
deleteRequest.setClassId(classId);
deleteRequest.setTransactionId(transactionId);
deleteRequest.setCorrelationId(correlationId);
deleteRequest.setNsdgTest(NSDGTest.NO );
SAPConnector connector = new SAPConnectorImpl();
deleteResponse = connector.makeDeleteRequest(deleteRequest );
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
37
Delete Response / Delete Acknowledgement
SAP (portal) Gateway
Delete Response / Delete Acknowledgement
Status =SUCESS
if(deleteResponse.getStatus().equals(RequestStatus.SUCCESS))
{ //Check what is received - Response or ACKNOWLEDGEMENT.
if(deleteResponse.getResponseDocumentType().equals(ResponseDocumentType.RESPONSE))
{ System.out.println("Response is received."); }
elseif(deleteResponse.getResponseDocumentType().equals(ResponseDocumentType.ACKNOWLEDGEMENT))
{
System.out.println("Correlation ID : "+deleteResponse.getCorrelationId());
System.out.println("Response End PointURL : "+deleteResponse.getResponseEndPointURL());
System.out.println("Poll Interval : "+deleteResponse.getPollInterval());
}
}
Status =FAILED
if(deleteResponse.getStatus().equals(RequestStatus.FAILED))
{
System.out.println("Request FAILED.");
String [] errors=deleteResponse.getErrors();
String error="";
for(int i=0;i<errors.length;i++)
{
System.out.println(errors[i]);
error=error+"\n"+errors[i];
}
}
Status = RESUBMIT
if(deleteResponse.getStatus().equals(RequestStatus.RESUBMIT))
{
System.out.println("Request failed. Please RESUBMIT.");
System.out.println(deleteResponse.getReason());
}
makeDeleteReques()
©Centre for Development of Advanced Computinghttp://nsdg.gov.in
38
Thank You