Quantcast
Channel: Discussion Forum > Connect Data Services
Viewing all articles
Browse latest Browse all 2504

The Java axis2 samples do not work (2 Comments)

$
0
0

Topic by Matthew Sreeves

The sample code needs to be significantly re-written to get it to work. For example, I've had to re-write the createSecurityHeader method as follows:

private OMElement createSecurityHeader(String username, String password)
{
        OMFactory factory = new SOAP11Factory();
        OMNamespace wsseNS = factory.createOMNamespace(WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
 
        OMElement usernameTokenElement = factory.createOMElement(WSConstants.USERNAME_TOKEN_LN, wsseNS);
 
        OMElement usernameElement = factory.createOMElement(WSConstants.USERNAME_LN, wsseNS);
        usernameElement.setText(username);
        usernameTokenElement.addChild(usernameElement);
 
        OMElement passwordElement = factory.createOMElement(WSConstants.PASSWORD_LN, wsseNS);
        passwordElement.setText(password);
        passwordElement.addAttribute(WSConstants.PASSWORD_TYPE_ATTR, WSConstants.PASSWORD_TEXT, null);
        usernameTokenElement.addChild(passwordElement);
 
        OMElement securityHeader = factory.createOMElement("Security", wsseNS);
        securityHeader.addAttribute("mustUnderstand", "1", null);
        securityHeader.addChild(usernameTokenElement);
       
   return securityHeader;
}    
 

 

Another example, when using the BasicQueryCSV.java. The sample gives the following code:

   String queryString = "SELECT Incident.ReferenceNumber, Incident.PrimaryContact.Contact.* FROM Incident";

   CSVTableSet queryCSV = _service.queryCSV(queryString, 10000, clientInfoHeader);

 

However, the only queryCSV method existing in my axis2 stubs is:   queryCSV(QueryCSVDocument, ClientInfoHeaderDocument)

 

This means I have to do the following instead:

   QueryMsgImpl queryMsg = new QueryMsgImpl(null);
 
   queryMsg.setQuery("SELECT Incident.ReferenceNumber, Incident.PrimaryContact.Contact.* FROM Incident");
 
   QueryCSVDocumentImpl queryCSVDocument = new QueryCSVDocumentImpl(null);
   queryCSVDocument.setQueryCSV(queryMsg);
 
   QueryCSVResponseDocument queryCSVResponseDocument = serviceStub.queryCSV(queryCSVDocument, clientInfoHeaderDocument);
 
 
Although even the above code is not quite correct, because the "null" parameters should be SchemaType objects - but I've no idea what to set these to!
 
Any ideas why "real life" doesn't tie in with the sample code?
 

Viewing all articles
Browse latest Browse all 2504

Trending Articles