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).

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0336199-d3c7-2c10-c983-f8a945a4588c?QuickLink=index&…

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(String.java:1937)

  at java.lang.String.substring(String.java:1904)

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((javax.xml.ws.BindingProvider) 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?

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

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

    Hi,

    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="http://sap.com/xi/BASIS" binding="bprf:BusinessComponentInBinding" name="BusinessComponentInPort">

    <soap:address location="/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>

    </wsdl:port>

    ...

    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

    http://<your_host>:<http_port>/BusinessComponentInService/BusinessComponentInImplBean?wsdl&mode=ws_policy

    Remove the URL parameters and you have the endpoint address:

    http://<your_host>:<http_port>/BusinessComponentInService/BusinessComponentInImplBean


    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:


    ....

    import com.sap.engine.services.webservices.espbase.client.api.HTTPControlFactory;

    import com.sap.engine.services.webservices.espbase.client.api.HTTPControlInterface;

    .....


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

    ....

        HTTPControlInterface httpInterface = HTTPControlFactory.getInterface(bindingProvider);

       httpInterface.setSocketTimeout(60000);

    }

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

    Regards,

    Frank

    Add comment
    10|10000 characters needed characters exceeded