390 likes | 542 Views
SSDG Connectors in Java. SAP Generic Application Specific SP Generic Application Specific. SAP Generic Connectors. Generic Synchronous API. makeSynchronousSubmitRequest() – making initial request to SSDG for availing a service in synchronous mode. Asynchronous API.
E N D
SSDG Connectors in Java
SAP • Generic • Application Specific • SP • Generic • Application Specific
Generic Synchronous API • makeSynchronousSubmitRequest() – making initial request to SSDG for availing a service in synchronous mode
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
Generic Responses • Success Status –Actual Response • Failed Status • Resubmit
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).
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.
Elements Element Name : Body Data Type : Object Mandatory : YES (for makeSynchronousSubmitRequest() , makeASynchronousSubmitRequest() ) Description : Payload for SP from SAP in the format understood by SP.
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.
Elements Element Name : responsemode Data Type : Enum Mandatory : YES (for all functions) Description :Type of response requested by the originator. • ResponseMode.ASYNCHRONOUS • ResponseMode.SYNCHRONOUS
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
Elements Element Name :starttime Data Type : Calendar Mandatory : YES (for function makeListRequest()) Description :Present for making list request calls
Elements Element Name : endtime Data Type : Calendar Mandatory : YES (for function makeListRequest()) Description :Present for making list request calls
Elements Element Name : targetendpointurl Data Type : String Mandatory : YES (for all functions) Description :URL of the Gateway
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)
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.CLEAR • SHA-1- AuthenticationType. ENCRYPTED • W3C signed- AuthenticationType.DIGITAL_SIGNATURE
Synchronous Submit Requestfrom SAP SP( Back off ) Gateway SAP (portal) 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);
Synchronous Response for Synchronous submit request SP Application Specific Connector Gateway SP Generic Connector callsyncSubmitRequest() //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; } 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 Sending Submit Response Sending Submit Response
Submit Response Gateway SAP (portal) 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()); Status =SUCESS if(submitResponse.getStatus().equalsRequestStatus.SUCCESS)) submitResponse.getResponse().toString()); Synchronous Response
Synchronous SUBMIT_REQUEST SAP (portal) Gateway SP( Back off ) Synchronous Submit Request Synchronous Submit Request Synchronous Response Synchronous Response
ASynchronous Submit Request SP( Back off ) Gateway SAP (portal) makeASynchronousSubmitRequest() callAsyncSubmitRequest() 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);
Asynchronous Request from SAP Gateway SP Generic Connector SP Application Specific Connector callAsyncSubmitRequest() 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; } 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 Submit Acknowledgement
Submit Acknowledgement SAP (portal) Gateway //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()); //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 =SUCESS if(submitResponse.getStatus().equalsRequestStatus.SUCCESS)) String corrId= submitResponse.getCorrelationId(); String responseendpointurl=submitResponse. getResponseEndPointURL (); Integer pollinterval=submitResponse. getPollInterval (); Submit Acknowledgement
Submit Poll SP( Back off ) Gateway SAP (portal) makeSubmitPoll() Submit Poll 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);
Submit Acknowledgement / Submit Response send to SAP from SP SP( Back off ) Gateway SAP (portal) 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()); Submit Response /Submit Acknowledgement Submit Response /Submit Acknowledgement
Asynchronous Communication SAP (portal) Gateway SP( Back off ) Asynchronous Submit Request Submit ACK Asynchronous Submit Request Submit ACK Submit poll Submit ACK Submit Response Submit ACK Submit poll RESPONSE
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);
List Request from SAP (List Request for Submit Requests from SAP to SP) SAP (portal) Gateway 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); List Response
List Response SAP (portal) Gateway makeListRequestforSubmitRequest() Status = RESUBMIT if(listResponse.getStatus().equals(RequestStatus.RESUBMIT)) { System.out.println("Request failed. Please RESUBMIT."); System.out.println(listResponse.getReason()); } 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 =SUCESS if(listResponse.getStatus().equalsRequestStatus.SUCCESS)) { System.out.println("LIST RESP DOC:"+listResponse.getResponse().toString()); } List Response
List Request SAP (portal) Gateway 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); List Response
List Response SAP (portal) Gateway makeListRequestforSubmitResponse() Status = RESUBMIT if(listResponse.getStatus().equals(RequestStatus.RESUBMIT)) { System.out.println("Request failed. Please RESUBMIT."); System.out.println(listResponse.getReason()); } 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 =SUCESS if(listResponse.getStatus().equalsRequestStatus.SUCCESS)) { System.out.println("LIST RESP DOC:"+listResponse.getResponse().toString()); } List Response
Delete Request SAP (portal) Gateway 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 ); Delete Response/Delete Acknowledgement
Delete Response / Delete Acknowledgement SAP (portal) Gateway makeDeleteReques() 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()); } Delete Response / Delete Acknowledgement