Skip to Content
avatar image
Former Member

Need help on Integration Directory API

Hi All,

I am trying to create ID objects by Using NWDS by using the code as mentioned in below link ( Integration Directory API).…

But while executing the program in NWDS i am getting the below error.

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -6

  at java.lang.String.substring(

  at java.lang.String.substring(

I have tracked the error. Exactly i am getting the error in below code:

// get port

BusinessSystemIn systemComp = service.getBusinessSystemInPort(); ( Note: NWDS is not allowinggetBusinessSystemInPort() instead of this i am using getBusinessSystemIn_Port())

// setup context and authorization

this.setupContext(( systemComp,

DirectoryApiConfiguration.getUserid(), DirectoryApiConfiguration.getPassword());

String addressTailWithHostAndPort = endpointAddress.substring(endPointPrefix.length());

All these three steps are interlinked.

Could you please check it once and let me know your suggestions where i am doing mistake or where i have to change?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jun 23, 2015 at 04:02 PM

    Hi Srikanth,

    What is your PI version?, are you sure that you are using the right NWDS?

    Have you tried to set log to know what are the variables content in each code step?


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 16, 2016 at 12:04 PM


    The respective coding in the SDN article assumes that the WSDL contains an endpoint address for the wrong PI host and port and tries to exchange it with your host. However, the error indicates that the WSDL does not contain an endpoint address at all, most probably the respective fragment looks like this:


    <wsdl:port xmlns:bprf="" binding="bprf:BusinessComponentInBinding" name="BusinessComponentInPort">

    <soap:address location="/" xmlns:soap=""/>



    There are different solutions for this. If you do not want to re-generate your consumer proxy then you should set a hard-coded endpoint address instead.

    So in the setupContext(BindingProvider bp, String user, String password) method, simply skip the String manipulation coding and set the address with

    context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);

    You can determine the endpoint adress in NWA -> Configuration -> Connectivity -> SingleServiceAdministration -> Service Definitions. Select the port type name of the Directory API service, in this example BusinessComponentIn (and NOT BusinessComponentVI, this is the PI 7.0 compatible Directory API service). Then select the "WSDLs" tab. Here you see a link like


    Remove the URL parameters and you have the endpoint address:


    If you don't mind re-generating the consumer proxy, then you can just download the WSDL zip file in this NWA page (button "ZIP Download"), extract the archive and create the proxy using the contained "main.wsdl" file.

    It will always contain the correct WSDL port so that you do not have to modify the address in the request context at all.

    One final recommendation: if you are using the Directory API for large update requests you can get issues with socket timeout. In this case it is advisable to increase the client timeout for your consumer proxy. You can do this by adding the following lines in the setupContext method:





    private final void setupContext(BindingProvider bindingProvider, String user, String password) {


        HTTPControlInterface httpInterface = HTTPControlFactory.getInterface(bindingProvider);



    Timeout is specified in milliseconds, so in the example above we have 10 minutes.



    Add comment
    10|10000 characters needed characters exceeded