Scalix API Sample Code?

Discuss the Scalix Messaging Services

Moderator: ScalixSupport

chengcsw
Posts: 20
Joined: Sat May 24, 2008 9:31 am

Scalix API Sample Code?

Postby chengcsw » Wed Jul 23, 2008 10:36 pm

Scalix told me that they cannot provide WSDL files for development. Therefore I cannot use Apache Axis or CXF to work with. I tried to code it with plain SAAJ.

Could anybody tell me what's wrong with my code?

Code: Select all

//First create the connection
SOAPConnectionFactory soapConnFactory =
      SOAPConnectionFactory.newInstance();
SOAPConnection connection =
      soapConnFactory.createConnection();

//Next, create the actual message
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();

//Create objects for the message parts
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();

//Populate the body
//Create the main element and namespace
SOAPElement bodyElement =
        body.addChildElement(envelope.createName("CAARequestMessage" ,
                                          "scalix-caa",
                          "http://www.scalix.com/caa"));

bodyElement.addChildElement(new QName("ServiceType"))
      .addTextNode("scalix.res");

SOAPElement identity = bodyElement.addChildElement(new QName("Credentials"))
      .addChildElement(new QName("Identity"));
identity.addAttribute(new QName("name"), "sxadmin");
identity.addAttribute(new QName("password"), "xxxxxx");

bodyElement.addChildElement(new QName("FunctionName"))
      .addTextNode("GetUsersList");

SOAPElement scalixElements = bodyElement.addChildElement(new QName("ScalixServers"));
scalixElements.addChildElement(new QName("Host")).addTextNode("obiwan.itc-hk.com");

SOAPElement getUsersListParameters = bodyElement
      .addChildElement("GetUsersListParameters");

getUsersListParameters.addAttribute(new QName("maxRecords"), "50")
      .addChildElement("filters")
         .addChildElement("usertypefiler")
            .addAttribute(new QName("value"), "ALL");
getUsersListParameters.addChildElement("organizedBy")
      .addAttribute(new QName("entity"), "LAST_NAME");

//Save the message
message.saveChanges();

//Check the input
System.out.println("\nREQUEST:\n");
message.writeTo(System.out);
System.out.println();

//Set the destination
String destination =
   "http://obiwan.itc-hk.com:80/caa";
//Send the message
SOAPMessage reply = connection.call(message, destination);

//Check the output
System.out.println("\nRESPONSE:\n");
//Create the transformer
TransformerFactory transformerFactory =
               TransformerFactory.newInstance();
Transformer transformer =
            transformerFactory.newTransformer();
//Extract the content of the reply
Source sourceContent = reply.getSOAPPart().getContent();
//Set the output for the transformation
StreamResult result = new StreamResult(System.out);
transformer.transform(sourceContent, result);
System.out.println();

//Close the connection
connection.close();

Return to “Scalix Messaging Services”



Who is online

Users browsing this forum: No registered users and 9 guests

cron