cancel
Showing results for 
Search instead for 
Did you mean: 

"Wrong format of delivery address:" and "OData Client - notification to - - failed - HTTP" when sending Push Notifications via SAP Backend

Former Member
0 Kudos

Hi experts,

Recently I am trying out SMP Push Notifications using this documentation http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40ab6d83-b7b8-3010-65bc-d7a08f0f3...

I believe many of the configurations is done. So I decided to try out the SAP Standard Demo Flight Service "RMTSAMPLEFLIGHT" starting page 14 in the document .

I did all the tasks from running SubscriptionCollections via rest client to running the sample standard program /IWBEP/R_MGW_PUSH_TEST in the program the sending was apparently successful but when I checked tcode SLG1 for the log I got these messages

I am not sure what these messages mean but in the case of the delivery address I am not sure why the format is incorrect. Since i tried both format specified in page 15 of the document:

  • urn:sap-com:channel :<RFC destination>:<request URI>
  • http(s)://<host>:<port>/..

Here are the records in table /IWBEP/D_MGW_SUB

I would like to hear from all of you soon


Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I Solved the "Wrong format of delivery address:" message OSS Note  2120880

But I am still getting the "OData Client - notification to  -  - failed - HTTP" error

EkanshCapgemini
Active Contributor
0 Kudos

Hi,

The OData client - notification to - - failed - HTTP error is caused due to problem in RFC destination pointing to the subscriber from the gateway system.

Please check the RFC destination.

Regards,

Ekansh

Former Member
0 Kudos

Thanks.

I resolved both issues.

To Fix  "Wrong format of delivery address:" message I applied OSS Note  2120880 (there's an earlier OSS note as well but for me it was already applied).

"OData Client - notification to  -  - failed - HTTP"

Yeah it had something to do with the RFC Destination.

I had to do the following:

1: Use user credentials of a Push User in the SMP. I had to ask someone to help with this.

2. Change the path prefix in the RFC Destination I created. The tutorial link specified /Push/ but it's a bit different in ours but I found out the HTTP to send push notifications is  "http://<host>:<proxy>/restnotification/application/<application ID from SMP Push>/"


so I had to change it from /Push/ to /restnotification/application/<application ID from SMP Push>/user


The "user" at the end is because I am sending Push Notifications per use. See "Users per application" section at link http://help.sap.com/saphelp_smp305svr/helpdata/en/6a/e1d7aabc2946c68d3c56acd42ec522/content.htm

Unfortunatley I still couldn't get the sample program to work. Thus we decided to just use the RFC and create a custom program and use the cl_http_client. It works.

So we just went with that.

EkanshCapgemini
Active Contributor
0 Kudos

Hi Charles,

Its good that finally it worked.

Can you please close the thread so that its easy for others to get the correct solution.

Answers (1)

Answers (1)

rakshit_doshi
Active Contributor
0 Kudos

Hi

Can you try to post the program here as well for reference.

Thanks,

Rakshit Doshi

Former Member
0 Kudos

Hi, here you go

*&---------------------------------------------------------------------*

*& Report  Z_PUSH_TEST

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT z_push_test.

TYPES: BEGIN OF ty_user,

        user(100) TYPE c,

       END OF ty_user.

DATA: lt_user TYPE STANDARD TABLE OF ty_user.

DATA: ls_user TYPE ty_user.

START-OF-SELECTION.

  PERFORM start.

* ---

FORM start.

  DATA: lv_status TYPE i,

        lv_error_occurred TYPE flag,

        lv_error_msg TYPE string,

        lv_response_body TYPE string.

  DATA: lv_json TYPE string.

  DATA: lv_url TYPE string.

* get your users from your table

  MOVE: '<specify SMP User or Registration Device>' TO ls_user-user.

  APPEND ls_user TO lt_user.

*  MOVE: '<specify other SMP User or Registration Device>' TO ls_user-user.

*  APPEND ls_user TO lt_user.

  LOOP AT lt_user INTO ls_user.

    CLEAR: lv_json.

    CONCATENATE '{ "notification": { "alert": "'

                'title'

                '", "data": "'

                'testData'

                '", "sound": "'

                'soundval'

                '" }, "users": [ "'

                ls_user-user

                '" ] }'

           INTO lv_json.

* SMP_PUSH is a configured RFC Destination and must be created

    PERFORM send_json

      USING 'SMP_PUSH'

            lv_json

      CHANGING lv_status lv_response_body

               lv_error_occurred

               lv_error_msg.

* Show result

    FORMAT COLOR OFF.

    WRITE: ls_user-user.

    FORMAT COLOR COL_HEADING.

    WRITE: / 'Response status:', lv_status.

    IF lv_error_occurred = 'X'.

      FORMAT COLOR COL_NEGATIVE.

      WRITE: / 'Error occurred:', lv_error_msg.

    ENDIF.

    FORMAT COLOR COL_NORMAL.

    WRITE: / 'Response:', lv_response_body.

    SKIP 2.

  ENDLOOP.

ENDFORM.                    "start

*&---------------------------------------------------------------------*

*&      Form  send_json

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      -->IV_URL             text

*      -->IV_JSON_DATA       text

*      -->CV_STATUS          text

*      -->CV_RESPONSE_BODY   text

*      -->CV_ERROR_OCCURRED  text

*      -->CV_ERROR_MSG       text

*----------------------------------------------------------------------*

FORM send_json USING iv_rfc

                     iv_json_data TYPE string

        CHANGING cv_status TYPE i

                 cv_response_body TYPE string

                 cv_error_occurred TYPE flag

                 cv_error_msg TYPE string.

  DATA: lo_client TYPE REF TO if_http_client.

  CLEAR: cv_error_msg,

         cv_status,

         cv_error_occurred,

         cv_error_msg.

  IF iv_rfc IS INITIAL.

* No URL passed

    MESSAGE e349(sbds) INTO cv_error_msg.

    cv_error_occurred = 'X'.

    RETURN.

  ENDIF.

  CALL METHOD cl_http_client=>create_by_destination

    EXPORTING

      destination              = iv_rfc

    IMPORTING

      client                   = lo_client

    EXCEPTIONS

      argument_not_found       = 1

      destination_not_found    = 2

      destination_no_authority = 3

      plugin_not_active        = 4

      internal_error           = 5

      OTHERS                   = 6.

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

     INTO cv_error_msg.

    cv_error_occurred = 'X'.

    RETURN.

  ENDIF.

*  CALL METHOD cl_http_client=>create_by_url

*    EXPORTING

*      url                = iv_url

*    IMPORTING

*      client             = lo_client

*    EXCEPTIONS

*      argument_not_found = 1

*      plugin_not_active  = 2

*      internal_error     = 3

*      OTHERS             = 4.

*  IF sy-subrc NE 0.

*    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

*      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

*     INTO cv_error_msg.

*    cv_error_occurred = 'X'.

*    RETURN.

*  ENDIF.

*

*  lo_client->propertytype_logon_popup = lo_client->co_disabled.

*  DATA l_username TYPE string.

*  DATA l_password TYPE string.

*  l_username = 'smpPushUser'.

*  l_password = 'Password101'.

*  CALL METHOD lo_client->authenticate

*    EXPORTING

*      username = l_username

*      password = l_password.

  lo_client->request->set_cdata( iv_json_data ).

  lo_client->request->set_content_type( 'application/json' ).

  lo_client->request->set_method( 'POST' ).

  CALL METHOD lo_client->send

    EXCEPTIONS

      http_communication_failure = 1

      http_invalid_state         = 2

      http_processing_failed     = 3

      OTHERS                     = 4.

  IF sy-subrc NE 0.

    lo_client->get_last_error( IMPORTING message = cv_error_msg ).

    cv_error_occurred = 'X'.

    RETURN.

  ENDIF.

  lo_client->receive( EXCEPTIONS OTHERS = 1 ).

  IF sy-subrc NE 0.

    lo_client->get_last_error( IMPORTING message = cv_error_msg ).

    cv_error_occurred = 'X'.

    RETURN.

  ENDIF.

  cv_response_body = lo_client->response->get_cdata( ).

  lo_client->response->get_status( IMPORTING code = cv_status ).

ENDFORM.                    "send_json

rakshit_doshi
Active Contributor
0 Kudos

Dear

I tried your program but i get the below error. Even on the SMP Server logs i see the same error.

Can you please assist

Regards,

Rakshit Doshi

Former Member
0 Kudos

You can check your RFC destination if it's configured properly.

Target Host is the SMP Server

And Path Prefix is the path prefix with the application id. Example /restnotification/application/<app id>/user/

You might want to check with the folks handling the SMP side of things to check on this.