Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
  1. Introduction:

    This is the 2nd part of Directory API development. The Directory API Development - Part 1 of 3 gave a high-level overview of directory API development and the pre-requisites of using the Directory API.

    In this 2nd part, we will explore the detail involving the development preparation required in NWDS before actual coding can begin.

    Then, in Directory API Development - Part 3 of 3, we will dive into the actual coding using the Directory API.

    To use as an example for this blog, I will use the Directory API to create SOAP receiver communication channels. The steps of creating other types of communication channels are similar. Primarily, the parameter names and the adapter type will need to be changed.

  2. Pre-Requisite of using the Directory API:

    As mentioned in Directory API Development - Part 1 of 3, to use the Directory API, the userid must be assigned specific roles. These roles must be assigned in the java server. The roles are not available using the ABAP transaction code SU01. It is critically important that step III in Directory API Development - Part 1 of 3 is carried out before proceeding with using the Directory API.
  3. Development Process:

    Please note, for this blog, NWDS 7.1 is used with PI 7.1.

    Overview:

    The development process consists of the following steps:
    1. Create project in NetWeaver Developer Studio
    2. Import the WSDL using one of the following methods:
      • URL location
      • WSDL file extracted from External Definition in the ESR (Note: with this, binding configuration in NWDS will be required)
    3. Generate client proxy from imported WSDL
    4. Develop program to use the API (during development the WSNavigator can be used to determine the required fields and keys to use.)

    This blog, part 2, covers the 1st 3 steps, and Directory API Development - Part 3 of 3 covers step 4.

    Step-by-Step:

    1. Create a "Java" project and include the following libraries in the build path:
      mailapi.jar
      saaj.jar
      wsdl4j-1.5.1.jar
      activation.jar
      axis.jar
      axis-ant.jar
      commons-discovery-0.2.jar
      commons-logging-1.0.4.jar
      jaxrpc.jar
      (These jar files can be found in the PI installation, or they can be downloaded from the internet.)

      For convenience, I included the above libraries in a user-library in NWDS.

      After project creation, my project, DirAPI_Blog, looks like the following:

    2. Import the WSDL using one of the following:
      1. From WSDL:

        This is an easier way of importing the WSDL, since the binding and endpoint are already in the WSDL URL. However, for some reason, specific to the Communication Channel webservice, we will receive an error when generating proxy using this import. Consequently, for this blog, this method should only be used as a reference to be used with other Directory API webservices. Please use step (B) for the exercise in this blog.

        1. The WSDL can be retrieved from /WSNavigator, by selecting the communication channel webservice

          Communication channel webservice:

          The URL:
          http://nspah227.pal.sap.corp:52700/CommunicationChannelService/HTTPBasicAuth?wsdl&style=document&mod...

          Copy-n-paste the URL into the following in NWDS.

        2. Right-click on the project and select "Import...":
        3. Select "WSDL" and click "Next":
        4. Select "Remote Location" and click "Next":
        5. Enter the WSDL URL of the webservice from above, and click "Finish":
        6. The java project will now have the following:

          When we double-click on the root WSDL, we will see that the bindings have already been included:

      2. From External Definitions (as an alternate method):
          As another option, we can export the external definition of the WSDL.
          The reason I am introducing this alternative method is because I have encountered situations when the previous method caused problems during the proxy generation step.
        1. In the Enterprise Service Repository (7.1) or the Integration Repository (7.0), double-click on the communication channel external definition:
        2. Export the WSDL to a file:
        3. As in steps ii, iii, iv and v in step (A) from above, we can enter the location of the file. But, please note, instead of the URL, we can enter the file where we exported the external definition. (Use the "Browse" button to select the file.)

          We should see the following in our project:

        4. However, now when we double-click on the "CommunicationChannel.wsdl", we do not see the binding:

          So, now, we have to create the binding and endpoint.

        5. To create the binding, on the right side of the display screen of "CommunicationChannel.wsdl", right-click on "Bindings" and select "Add Binding":
        6. In the "Property" tab on the bottom, enter any name for the binding name, and select the Port Type, using the dropdown: (In this example, I gave "HTTPBinding" as the binding name. The port type, CommunicationChannelServiceVi_Document, is already in the WSDL file, so there is no need to create another one.)
        7. Click on "Generating Binding Content...":

          and, select "SOAP" for the protocol:

        8. Now, we can create the service. Right-click on "Services" and select "Add Service":
        9. Enter any service name. In this example, I entered "HTTPService":
        10. A "NewPort" will automatically be created for the service. Assign a new port name to the service and select the binding created above in the dropdown: (In the example, I gave "HTTPPort" as the port name.)
        11. Enter the WSDL URL of the communication channel webservice into the address field:
        12. Now, we see the binding and endpoints are present in the display:

          Save the wsdl file.

    3. Generate the Proxy Client from the WSDL

      If you used step (A) to import the WSDL, you will encounter a proxy-generation error: IWAB0399E Error in generating Java from WSDL: java.lang.NullPointerException

      This error seems to occur only with the Communication Channel webservice. As a result, I will generate the proxy using the WSDL from step (B) above. If you have already done step (A), you can delete the 4 WSDLs created from the import and redo the import using step (B).

      1. Generate the java proxy by right-click on CommunicationChannel.wsdl, select "Webservices" and click on "Generate Client".
        (Sorry the screenshot is so small...there is nothing I can do due to the graphic limitation placed for blogs.)
      2. Slide the scale to "Develop Client", select "Overwrite files without warning", and click on "Finish":
      3. After the proxy generation, you should have the following, with the newly created packages:

        Note: If step (A) was used during the import, then you will need to do this for all of the 4 WSDLs created from the import.

      4. Because we will also create changelist and activate the communication channel configruations, please repeat the above steps to import the WSDL URL for the changelist. We can use the URL instead of using external definition. After importing the WSDL URL and generating the proxy for the WSDLs, we should have the following:

        Note: Do not forget to generate the java proxies for all the WSDLs created after importing the WSDL URL.

        Because we imported the WSDL URL instead of using the external definition, there is no need to go thru the steps in the configuration of the binding and endpoint. We can just generate the java proxies after importing the WSDL URL.

    4. Create Java Client Program: go to Directory API Development - Part 3 of 3
10 Comments