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