cancel
Showing results for 
Search instead for 
Did you mean: 

Null response to integration directory API request

steve_coombes
Participant
0 Kudos

Hello,

I would like to get a list of Communication Channels using the ID API. I have created a Java client and can send a query. I can see the SOAP response

if I send the request via anapplication called TCP-trace. However the response in Java is null.

We are using PI 7.1. I used NWDS 7.3 to create bindings in

the CommunicationChannelServiceVi WSD. Then I used JAX-WS to create a Java client.

My code doesn't look all that great (see below) but the request does seem to work.

>>>>

  CommunicationChannelServiceViDocumentService service = new CommunicationChannelServiceViDocumentService();
  CommunicationChannelServiceViDocument port = service.getCommunicationChannelServiceViDocumentPort();
 
  ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://xxx/CommunicationChannelService/HTTPBasicAuth");
  ((BindingProvider)port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "xxxxx");
  ((BindingProvider)port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "xxx");

  // Create communication channel query
  CommunicationChannelQueryIn communicationChannelQueryRequest = new CommunicationChannelQueryIn();

  // Set value to * to return all communication channels
  JAXBElement<String> valueElement = new JAXBElement<String>(new QName("urn:com.sap.aii.ibdir.server.api.types","value"), String.class, "*" );
 
  // Create description element containing value
  ObjectFactory factory = new ObjectFactory();
  LONGDescription desc = factory.createLONGDescription();
  desc.setValue(valueElement);
 
  JAXBElement<LONGDescription> descriptionElement = new JAXBElement<LONGDescription>(new QName("urn:com.sap.aii.ibdir.server.api.types","Description"), types.api.server.ib.aii.sap.com.LONGDescription.class, desc);
 
  communicationChannelQueryRequest.setDescription(descriptionElement);
 
  // Send request
  CommunicationChannelQueryOut response = port.query(communicationChannelQueryRequest);

<<<<<

The

CommunicationChannelQueryOut object is null.

The SOAP response seems fine :

>>>>>

<SOAP-ENV:Body xmlns:rpl='urn:CommunicationChannelServiceVi'><rpl:queryResponse xmlns:rn1='http://schemas.xmlsoap.org/soap/encoding/' xmlns:rn0='urn:com.sap.aii.ib.server.api.types' xmlns:rn3='urn:com.sap.aii.ibdir.server.api.types' xmlns:rn2='java:sap/standard'><Response><rn3:CommunicationChannelID><rn3:PartyID></rn3:PartyID><rn3:ComponentID>xxxx</rn3:ComponentID>

...

<<<<<

Kind regards

Steve

Accepted Solutions (1)

Accepted Solutions (1)

marksmyth
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Steve,

Have you seen these blogs - Directory API Development - Part 1 of 3. Perhaps these will help you out.

Regards

Mark

steve_coombes
Participant
0 Kudos

Hello Mark

Thanks, I have been using that blog. It is very useful.

I think that the problem might be due to the namespace of the response.

The Java client seems to expect the <Response> element to be in a namespace, but it isn't.

regards

Steve

Answers (1)

Answers (1)

anandvithal
Active Participant
0 Kudos

Hi Steve,

The Query operation takes CommunicationChannelQueryIn as request and returns CommunicationChannelQueryOut.

CommunicationChannelQueryIn request must have ChannelID set with communication channel name as "*"(party and service you can ignore,if its not your filter criteria).

here is my piece of working code

     

    String channel = "*";

     types.api.server.ibdir.aii.sap.com.ObjectFactory specificObj = new types.api.server.ibdir.aii.sap.com.ObjectFactory();
    CommunicationChannelQueryOut res = null;
    try
    {
      CommunicationChannelQueryIn req = new CommunicationChannelQueryIn();
      CommunicationChannelID cc = new CommunicationChannelID();
      cc.setChannelID(specificObj.createCommunicationChannelIDChannelID(channel));
      req.setCommunicationChannelID(specificObj.createCommunicationChannelCommunicationChannelID(cc));

      res = port.query(req);
      if (res.getCommunicationChannelID().isEmpty())
      {
        System.out.println("No results for :" + channel);
        return null;
      }
    }

Regards,

Anand

steve_coombes
Participant
0 Kudos

Many thanks Anand.

I get the same null pointer exception with your code when calling a method on the CommunicationChannelQueryOut response.

I am still using the jax-ws client.

I am using jax-ws because I am used to it, and I couldn't see how to set the Basic Authentication username and password using Axis.

Does your code run on Axis or jax-ws? Or both?

regards

Steve

anandvithal
Active Participant
0 Kudos

Hi Steve,

Am using javax client with basic http authentication.

I bind the user, password and endpoint as below

bp.getRequestContext().put("javax.xml.ws.security.auth.username", "myuser");

bp.getRequestContext().put("javax.xml.ws.security.auth.password", "mypassowrd");

bp.getRequestContext().put("javax.xml.ws.service.endpoint.address", "http://" + "myhost" + ":" + "myport" + "/CommunicationChannelService/HTTPBasicAuth?wsdl&style=document&mode=ws_policy");

Could you check the endpoint URL that you are using?.

And also test the webservice in WSNAVIGATOR and with the user and password that you are using.

Thanks,

Anand