Skip to Content
  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:

      image

    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

          image

          Communication channel webservice:
          image

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

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

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

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

      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:
          image
        2. Export the WSDL to a file:
          image
        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.)
          image

          We should see the following in our project: image

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

          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”:
          image
        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.)
          image
        7. Click on “Generating Binding Content…”: image

          and, select “SOAP” for the protocol:
          image

        8. Now, we can create the service. Right-click on “Services” and select “Add Service”: image
        9. Enter any service name. In this example, I entered “HTTPService”:
          image
        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.)
          image
        11. Enter the WSDL URL of the communication channel webservice into the address field:
          image
        12. Now, we see the binding and endpoints are present in the display:
          image

          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.)
        image
      2. Slide the scale to “Develop Client”, select “Overwrite files without warning”, and click on “Finish”:
        image
      3. After the proxy generation, you should have the following, with the newly created packages:
        image

        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.

        image

    4. Create Java Client Program: go to Directory API Development – Part 3 of 3
To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

  1. senthil Nathan K
    Hi Bill,

    Thanks for the very intresting blog and a detailed one. However, i am not able to see any external definitions under the SAP Basis 7.1, http://sap.com/xi/XI/System. I have assigned the roles as mentioned in the blog. Please guide me what settings needed to get the External Definitions under SAP BASIS.

    Thanks & Regards,
    Senthil.

    (0) 
    1. William Li Post author
      Hi,
      External definitions areno longer available in PI 7.1.  They are available as interfaces, which have to be imported from the ESR in NWDS.  However, the webservices for the interfaces are available from PI 7.11.

      Therefore, the PI 7.0 external definitions have to be used on PI 7.1.

      Regards,
      Bill

      (0) 
      1. rajat kumar

        Hi William,

        Can we create any such utility using notepad ?

        I don’t want to use Excel to create the channels.

        Any idea on this then please suggest how to go about it.

        Regards

        Rajat

        (0) 
  2. Venkat Nimmagadda

    Hi William,

    Thanks for writing a great blog.I’m trying to to work on IDAPI for PI 7.1 .I couldn’t able to find the complete jar files that you mentioned. I tried to search the jar files in PI server and also searched in net for the same ;but end up with no luck.

    Could you please help me out.

    (0) 
    1. Shankar Narayanan

      Depends upon which PI system you are accessing. For client’s PI system, it should obviously work. For other PI systems, if your network settings allows to connect, yes you can !

      (0) 
      1. rajat kumar

        I am connect to client network via VPN and able to access the client PI system.

        Have all the necessary roles also assigned.

        But when i am trying to run the file via cmd it gives me the below error:


        java.net.SocketException: Unexpected end of file from server


        Though the same set of steps are working for me if i am trying to connect to the local PI server without VPN.


        Regards

        Rajat

        (0) 

Leave a Reply