Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Can CF10 handle createobject/webservice calls directly to a CXF based webservice?

New Here ,
Aug 22, 2012 Aug 22, 2012

There are a number of blog discussions out there that show workarounds for calling CXF webservices using createobject/java, cfinvoke, etc.These methods require that you actually write out the actual SOAP request, or create and use java objects.  Can CF10 handle CXF based webservices more directly?  Is there an argument that can be set in the createobject or cfobject call to do this?

Some blog links on subject:

http://onlineanthony.blogspot.com/2010/05/using-ws-security-for-soap-in.html

http://tjordahl.blogspot.com/2009/04/make-coldfusion-8-work-with-apache-cxf.html

838
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2012 Aug 28, 2012
LATEST

I was able to work through this on my own.  (A bit more work then necessary since many of the ColdFusion Documentation's SOAP Examples are broken.)  My code creates an XML structure that matches the wsse:Security request header.  I got the header info by sniffing the webservice call made from a Java application.  Here is the code:

<cfscript>

    wsObj = CreateObject("webservice", "http://gall.blackbean.com/protex-sdk/v6_1/user?wsdl");

  

    // Create the WS Security Header as a CFML XML object.

    doc = XmlNew();

    doc.xmlRoot = XmlElemNew(doc, "wsse:Security");

    xmlAttrib1Struct["xmlns:wsse"] = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";

    doc.xmlRoot.XmlAttributes = xmlAttrib1Struct;

   

    // Create wsse:UsernameToken

    doc.xmlRoot.XmlChildren[1] = XmlElemNew(doc, "wsse:UsernameToken");

    UsernameTokenAttribStruct["wsu:Id"] = "UsernameToken-24";

    UsernameTokenAttribStruct["xmlns:wsse"] = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";

    UsernameTokenAttribStruct["xmlns:wsu"] = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";

    doc.xmlRoot["wsse:UsernameToken"].XmlAttributes = UsernameTokenAttribStruct;

   

    // Create wsse:UserName and add to UserNameToken

    doc.xmlRoot["wsse:UsernameToken"].XmlChildren[1] = XmlElemNew(doc, "wsse:Username");

    doc.xmlRoot["wsse:UsernameToken"]["wsse:Username"].XmlText = "smith@blackbean.com";

    StructDelete(doc.xmlRoot["wsse:UsernameToken"]["wsse:Username"], "XmlAttributes");

    // Create wsse:Password_Text and add to UserNameToken

    doc.xmlRoot["wsse:UsernameToken"].XmlChildren[2] = XmlElemNew(doc, "wsse:Password");

    doc.xmlRoot["wsse:UsernameToken"]["wsse:Password"].XmlText = "beans";

    PasswordAttribStruct["Type"] = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0" & Chr(35) & "PasswordText";

    doc.xmlRoot["wsse:UsernameToken"]["wsse:Password"].XmlAttributes = PasswordAttribStruct;

   

    //WriteDump(doc);

   

    addSOAPRequestHeader(wsObj, "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse:Security", doc);

   

    ret = wsObj.GetUserByEmail("smith@blackbean.com");   

   

</cfscript>

<cfoutput>

    This is the user's firstname: #ret.getFirstName()#<br/>

    This is the user's lastname: #ret.getLastName()#<br/>

    This is the user's Email: #ret.getEmail()#\

</cfoutput>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources