How to get delivery report from SMSC using Jamaa-Smpp and C#? - sms-gateway

How to get delivery report from SMSC using Jamaa-Smpp and C#?
Thanks in advance,

We can get delivery report in Jamaa-Smpp by using client_MessageDelivered event
First ,we need to use this code:
SmppClient(); client = new SmppClient();
client.MessageDelivered += new EventHandler<MessageEventArgs>(client_MessageDelivered);
Second , we need to use this code:
void client_MessageDelivered(object sender, MessageEventArgs e)
{
TextMessage msg = e.ShortMessage as TextMessage;
string msgtext=msg.text;
}
and do not forget to set value to SubmitSm.RegisteredDelivery as your work requirements:
//SMSC delivery receipt requested where final delivery outcome is deliver success or failure
SubmitSm.RegisteredDelivery = RegisteredDelivery.DeliveryReceipt;
or
//SMSC delivery receipt requested where the final delivery outcome is delivery failure
SubmitSm.RegisteredDelivery = RegisteredDelivery.DeliveryReceiptFailure;

Related

Error when sending message to Bloomberg via QuickFixJ

I'm trying to sending packet type X to Bloomberg via QuickFixJ. I'm able to connect successfully but when I send the packet, I receive an error message :
8=FIXT.1.1^A9=160^A35=X^A34=4^A49=ARHGBETA^A52=20210915-13:16:04.156^A56=BBGBETA^A1022=****^A22=1^A48=BQ4434677^A268=2^A279=0^A269=0^A270=99.00357818603516^A279=0^A269=1^A270=99.01358032226562^A10=060^A
8=FIXT.1.1^A9=253^A35=j^A49=BBGBETA^A56=ARHGBETA^A34=4^A52=20210915-13:16:04.380^A45=4^A372=X^A380=0^A58=Validation failed for incoming X packet:
In mDIncGrp: In groupMDEntries[0]: NULL component instrument_MarketData
In groupMDEntries[1]: NULL component instrument_MarketData
And yet, I don't see how to define the component instrument_MarketData. I'm using the following code to generate the groups:
/**
* Méthode de création d'un nouveau prix pour le publier sur Bloomberg
* #param marketPrice
* */
public MarketDataIncrementalRefresh createMarketDataIncrementalRefresh(MarketPrice marketPrice) {
quickfix.fix50sp2.MarketDataIncrementalRefresh message = new MarketDataIncrementalRefresh();
quickfix.fix50sp2.MarketDataIncrementalRefresh.NoMDEntries group = new MarketDataIncrementalRefresh.NoMDEntries();
message.getHeader().setString(1022, "****");
quickfix.fix50sp2.component.MDIncGrp mdIncGrp = new MDIncGrp();
mdIncGrp.setString(48, marketPrice.getCUSIP());
mdIncGrp.setString(22, "1");
Instrument instrument =new Instrument();
/**
* Ajout prix Bid au message
* */
instrument.setString(279, "0");
instrument.setString(269, "0");
instrument.setString(270, marketPrice.getBid_kech().toString());
group.set(instrument);
mdIncGrp.addGroup(group);
/**
* Ajout prix Ask au message
* */
instrument.setString(279, "0");
instrument.setString(269, "1");
instrument.setString(270, marketPrice.getAsk_kech().toString());
group.set(instrument);
mdIncGrp.addGroup(group);
message.set(mdIncGrp);
return message;
}
What am I doing wrong? Should I define a custom dictionary to be able to send the message or can I do it with the default dictionary?
Many thanks in advance !
You do not need a custom dictionary to send custom messages. Dictionary validation is only done for received messages, so you might need to alter your dictionary to successfully receive the responses sent by your counterparty.
As to your problem: the error sounds as if something is missing in your group regarding the instrument. Looking at your code I think you mix up the group stuff a bit. I posted this link for an earlier question of you: https://www.quickfixj.org/usermanual/2.3.0/usage/repeating_groups.html
I think the important part is that you should add the group to the message like so:
quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries group =
new quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries();
group.set(new MDEntryType('0'));
group.set(new MDEntryPx(12.32));
group.set(new MDEntrySize(100));
group.set(new OrderID("ORDERID"));
message.addGroup(group); // important part
In your code you are adding a group to a group (mdIncGrp.addGroup(group)) and do a message.set(mdIncGrp) where you really should use addGroup(). Because of this the 48/SecurityID field does not end up in the MDIncGrp but the root message.
8=FIXT.1.1^....removed...^A22=1^A48=BQ4434677^A268=2^A279=0^A269=0^A270=99.00357818603516^A279=0^A269=1^A270=99.01358032226562^A10=060^A
^^^ 48 is here where it should really
be in each of these groups starting with delimiter tag 279

having same delivery_sm with same MessageId every time

I'm trying to implement smpp solution using opensmpp. Messages are sent succefully but for delivery receipts, I get only for some submited message and the same delivery receipts came several times. Can someone help me please.
private void receiveSms() {
try {
if (session != null && session.isBound()) {
PDU pdu = session.receive(1500);
if (pdu instanceof DeliverSM) {
DeliverSM received = (DeliverSM) pdu;
if (received.getEsmClass() == 0) {
// new message
System.out.println("RECEIVE NEW MESSAGE " + received.debugString());
} else {
//delivry Repport
System.out.println("RECEIVE NEW DELIVERED REPORT: " + received.debugString());
}
}
}
...
I am not familliar with opensmpp, but note that the messageId in norm smpp34 is still NULL,
The messageId associated to SUBMIT_SM is in DELIVER_SM "receipted_message_id" field,
or in the short_message if the appendixB is used,
If the "receipted_message_id" field has always the same value, you should check about the SMSC configuration/code, the DELIVER_SM is generated there

How does ibm - mobile first get mobile number from security context?

I am following "isRegistered" api from this sample code. I did not understand how we get phone number from security context.
The API that I want to use is:
#Path("/isRegistered")
#GET
#Produces("application/json")
#OAuthSecurity(enabled = true)
#ApiOperation(value = "Check if a phone number is registered",
notes = "Check if a phone number is registered",
httpMethod = "GET",
response = Boolean.class
)
#ApiResponses(value = {
#ApiResponse(code = 200, message = "OK",
response = String.class),
#ApiResponse(code = 401, message = "Not Authorized",
response = String.class),
#ApiResponse(code = 500, message = "Cannot check if phone number is registered",
response = String.class)
})
public Boolean isRegistered() {
//Getting client data from the security context
ClientData clientData = securityContext.getClientRegistrationData();
if (clientData == null) {
throw new InternalServerErrorException("This check allowed only from a mobile device.");
}
String number = clientData.getProtectedAttributes().get(SMSOTPSecurityCheck.PHONE_NUMBER);
return number != null && !number.trim().equals("");
}
How does the security context have the client phone number?
There is a client project as well in this sample. Please refer to the complete sample.
Within the client side logic here, the user is asked to provide the phone number , which is sent to the server in an adapter call:
MainViewController.codeDialog("Phone Number", message: "Please provide your phone number",isCode: true) { (phone, ok) -> Void in
if ok {
let resourseRequest = WLResourceRequest(URL: NSURL(string:"/adapters/smsOtp/phone/register/\(phone)")!, method:"POST")
.....
Now in the adapter code path #Path("/register/{phoneNumber}") notice the following code:
clientData.getProtectedAttributes().put(SMSOTPSecurityCheck.PHONE_NUMBER, phoneNumber);
securityContext.storeClientRegistrationData(clientData);
This is how the phone number made it to the security context.
Run the sample and use a tool such as Wireshark to analyze the data flow between client and server.

Unable to create Sales Order from JCO

I am using the below code to call the BAPI BAPI_SALESORDER_CREATEFROMDAT2 to create the sales order . SAP machine is generating a SO number and sending as a response but when i check with va03 for the SO number which i have received sales order is not created .
If i do manually using va01 with the same data i can create the sales order successfully. Please need help on this .
public static void createSalesOrder() {
try {
JCoDestination destination = JCoDestinationManager.getDestination("ABAP_AS_WITH_POOL");
JCoFunction functionCreateOrder = destination.getRepository().getFunction("BAPI_SALESORDER_CREATEFROMDAT2");
//this is the bapi
JCoFunction functionTransComit = destination.getRepository().getFunction("BAPI_TRANSACTION_COMMIT");
JCoStructure orderHeaderIn = functionCreateOrder.getImportParameterList().getStructure("ORDER_HEADER_IN");
orderHeaderIn.setValue("SALES_ORG", "2000");//sales organisation
orderHeaderIn.setValue("DISTR_CHAN", "20");//distribution channel
orderHeaderIn.setValue("DIVISION", "20");// sales division
orderHeaderIn.setValue("DOC_TYPE", "ZAR");// document type
orderHeaderIn.setValue("PURCH_NO_C", "TEST123");
JCoTable orderPartners = functionCreateOrder.getTableParameterList().getTable("ORDER_PARTNERS");
// WE,AG,SP,PH
// AG Sold to Party
// WE Ship to Partyx
orderPartners.appendRow();
orderPartners.setValue("PARTN_ROLE", "AG");//partner role ag is sold to party
orderPartners.setValue("PARTN_NUMB", "0000000035");// partner number
orderPartners.appendRow();
orderPartners.setValue("PARTN_ROLE", "WE");//we is ship tp party
orderPartners.setValue("PARTN_NUMB", "0000000035");// partner number
System.out.println(orderPartners);
JCoTable orderItemsIn = functionCreateOrder.getTableParameterList().getTable("ORDER_ITEMS_IN");
orderItemsIn.appendRow();
orderItemsIn.setValue("MATERIAL", "PEN_ARN");// material
System.out.println(orderItemsIn);
JCoTable orderSchedulesIn = functionCreateOrder.getTableParameterList().getTable("ORDER_SCHEDULES_IN");
orderSchedulesIn.appendRow();
orderSchedulesIn.setValue("REQ_QTY", "10");// required quantity
System.out.println(orderSchedulesIn);
functionCreateOrder.execute(destination);
// System.out.println(functionCreateOrder);
JCoTable returnTable = functionCreateOrder.getTableParameterList().getTable("RETURN");
System.out.println(returnTable);
System.out.println(returnTable.getString("MESSAGE"));
System.out.println("sales order number is : "
+ functionCreateOrder.getExportParameterList().getValue("SALESDOCUMENT"));
functionTransComit.execute(destination);
} catch (JCoException ex) {
System.out.println(ex.getMessage());
} finally {
System.out.println("Creating sales order ends");
}
}
This depends on your JCo version, but at least with JCo 3 you need to execute your call to BAPI_TRANSACTION_COMMIT within the same context as your function call to BAPI_SALESORDER_CREATEFROMDAT2. Currently both calls are executed in individual contexts, so the second call to BAPI_TRANSACTION_COMMIT doesn't really commit anything. You have to create a context first:
JCoContext.begin(destination);
// execute both function calls to
// BAPI_SALESORDER_CREATEFROMDAT2 and
// BAPI_TRANSACTION_COMMIT
JCoContext.end(destination);

In Bloomberg API how do you specify to get FX forwards as a spread rather than absolute values?

How do you explicitly request fx forwards as outrights using the bloomberg API?
In the Bloomberg terminal you can choose whether to get FX Forwards as absolute rates (outrights) or as offsets from Spots (Points) by doing XDF, hitting 7, then the option is about half way down. 0 means outrights, and 1 means offfsets.
With most defaults you can explicitly set them in the API, so your code gives the same result whichever computer you run on. How do you set this one in a V3 API query?
Having had a colleague told by the help desk this is impossible, it turns out they are wrong and it is possible. You override the FWD_CURVE_QUOTE_FORMAT to be RATES for absolute and POINTS as offsets.
Example code (Java):
public static void main(String [] args) throws Exception{
Session session = BlpUtil.connectToReferenceData();
Service refDataService = session.getService("//blp/refdata");
Request request = refDataService.createRequest("HistoricalDataRequest");
Element securities = request.getElement("securities");
securities.appendValue("JPY10Y CMPL Curncy");
Element fields = request.getElement("fields");
fields.appendValue("PX_LAST");
request.set("startDate", "20100527");
request.set("endDate", "20100527");
Element overrides = request.getElement("overrides");
Element override1 = overrides.appendElement();
override1.setElement("fieldId", "FWD_CURVE_QUOTE_FORMAT");
override1.setElement("value", "POINTS");
CorrelationID cid = session.sendRequest(request, null);
while (true) {
Event event = session.nextEvent();
MessageIterator msgIter = event.messageIterator();
while (msgIter.hasNext()) {
Message msg = msgIter.next();
if (msg.correlationID() == cid) {
System.out.println("msg = " + msg);
}
}
}
}