anothernoc
anothernoc

Reputation: 177

RESTful services with AXL

I am trying to create a few restful webservices that will add a bit functionality to the company cisco phones. The basic idea is simple, the users get a small client on which they need to enter login and password. When they have done so, their phone/phones are 'registered' to my restful service and they get added functions on their phone. When they log out, they get unregistered. To provide the extra functions (like adjusted caller information etc etc) I need the Cisco AXL API. This is a SOAP based API. I have generated the java classes using the wsdl already. When I make a testclient using the generated classes, all works fine.

But here comes the problem: When I try to run a soap request while my application is deployed on my Tomcat 7 container, it doesn't work anymore.

The problem seems to be the AXLAPIService, which hangs when executing the following piece of code:

@WebEndpoint(name = "AXLPort")
public AXLPort getAXLPort() {
    return super.getPort(new QName("http://www.cisco.com/AXLAPIService/", "AXLPort"), AXLPort.class);
}

In other words, i am not getting a port for the soap request and it makes the tomcat crash i f you wait long enough.

I went googling. Somebody on some forum once had a problem because of an out of date stax version. I adjusted the stax version in my POM and tried again, to no help.

I also read somewhere that the underlaying javax.xml.ws.Service actually has an enumeration of ports, and when you do getPort(), you will get the most appropiate port. I then looked up the default port for SOAP and that would be 80, just like the port used for RESTful services. Could it be that the soap service would be wanting port 80, but that it can't have it because it is already in use?

So, to summarize my question:

As additional information, this is how the axl wsdl defines the service:

<service name="AXLAPIService">
<port binding="s0:AXLAPIBinding" name="AXLPort">
  <soap:address location="https://CCMSERVERNAME:8443/axl/"/>
</port>

I was thinking about changing the soap port myself. Some googling tells me I should do that in the wsdl but I wouldn't really know how. There is post already here but I fail to see how binding another portname could help me out....

Upvotes: 0

Views: 819

Answers (1)

anothernoc
anothernoc

Reputation: 177

As with so many things involving Cisco Telephony and their Administrative XmL (AXL), I found a workaround instead of an actual answer. Since a problem never really leaves my mind, I spent the rest of yesterday trying to find a solution for getting information out of that AXL thing.

Any actual answers to the above questions are still welcome though.

The workaround I found is this: Since SOAP can be seen as a special http POST request, it should be possible to do a SOAP call using a REST framework such as Jersey. You just need some extra code to make it work. I used the 'SoapProvider' from the link and for those who are also wrestling with this, I'll add my code:

public void doSoapRequest() throws SOAPException, JAXBException{


    ClientConfig config = new DefaultClientConfig();
    config.getClasses().add(SoapProvider.class);
    Client c = Client.create(config);
    c.addFilter(new LoggingFilter());
    c.addFilter(new HTTPBasicAuthFilter("user", "password"));

    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage message = messageFactory.createMessage();
    SOAPPart soapPart = message.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();
    SOAPBody body = envelope.getBody();
    SOAPElement bodyElement = body.addChildElement(envelope.createName("getCCMVersion", "", "http://www.cisco.com/AXL/API/8.5"));
    message.saveChanges();

    WebResource service = c.resource("https://youraxlmachine:8443/axl/");


    // POST the request
    ClientResponse cr = service.type(MediaType.TEXT_XML).header("SOAPAction", "\"https://youraxlmachine:8443/axl/getCCMVersion\"").post(ClientResponse.class, message);
    message = cr.getEntity(SOAPMessage.class);



    JAXBContext ctx = JAXBContext.newInstance(GetCCMVersionRes.class);
    Unmarshaller um = ctx.createUnmarshaller();
    GetCCMVersionRes response = (um.unmarshal(message.getSOAPPart().getEnvelope().getBody().extractContentAsDocument(), GetCCMVersionRes.class)).getValue();
    System.out.println("HERE COMES THE VERSION!");
    System.out.println(response.getReturn().getComponentVersion().getVersion());
}

I have left as many things unchanged as I could, except for the company specific details. This code works for getting the CCM version.

WARNING: Depending on how you perform the request, you might get a different result for the same request. I'll explain:

I have implemented other AXL methods as well, such as getUser. Before I even coding the Jersey soap service, I tried everything with SOAPUI. So I setup the SOAPUI so I could do RESTful requests to the AXL server. Using my restful setup in SOAPUI, I get the same results as I when would do the standard SOAP calls using both SOAPUI and my first implementation of a soapclient in java.

But when I use the jersey client to do the same getUser request, some important fields are missing from the result. I have no clue what could have caused this. For the request getPhone, I dont even get a valid response. So be warned.

Upvotes: 0

Related Questions