House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / Java

Web Services :: Java to Coldfusion CFC

Author:
James Holmes
10/13/2009 10:26 PM

I'd chuck out the WSDL part of the call and just call the CFC directly. mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ > > Hello, > > We are currently developing a BlackBerry application to pull information from an XML file generated by ColdFusion web services.  Information entered into our website (written in ColdFusion) is saved into a MySQL database and XML file.  A CFC exists containing functions to read and parse through the XML files and return the information needed from the files. > > The BlackBerry application (written in Java) needs to be able to call these functions in the CFC and grab the returned information (XML file). > > An example of one of the functions in our Webservices.cfc CFC is this: > > <cffunction name="fcnAccountsGet" returntype="xml" access="remote"> >    <cffile action="read" file="___fileLocation___" variable="fileData"> >    <cfset xmlData = XMLParse(fileData)> >    <cfreturn xmlData> > </cffunction> > > This function reads the XML file and returns its' contents.  We are calling this CFC from the Java app like this: > > http://www.ourwebsite.com/WebServices.cfc?WSDL > > > And here is the Java code: > > String serviceUrl="http://www.ourwebsite.com/WebServices.cfc?WSDL"; >          String namespace="http://www.ourwebsite.com/"; >          String action="fcnAccountsGet"; >          String method="fcnAccountsGet"; > > >   private void getXMLConfigData() >    { >         try >        { >            // Build a document based on the XML file. >            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); >            DocumentBuilder builder = factory.newDocumentBuilder(); > >            InputStream inputStream = getClass().getResourceAsStream( _xmlConfigFileName ); >            Document document = builder.parse( inputStream ); > >            // Normalize the root element of the XML document.  This ensures that all Text >            // nodes under the root node are put into a "normal" form, which means that >            // there are neither adjacent Text nodes nor empty Text nodes in the document. >            // See Node.normalize(). >            Element rootElement = document.getDocumentElement(); >            rootElement.normalize(); > >            NodeList nodeLst = rootElement.getChildNodes(); >            //private static final String XPATH_EXPRESSION = "/traceGroup/trace/text()"; > >            boolean skip = false; >            for (int i = 0; i < nodeLst.getLength(); i++) >            { > >                Node n = nodeLst.item(i); >                String nameNode = n.getNodeName(); >                if(nameNode.equals("Login")) >                { >                    String LoginValue = n.getFirstChild().getNodeValue(); >                    if(LoginValue.equals("1")) >                    { >                        skip = true; >                    } >                    break; >                } >            } > >            if(skip == true) >            { > >               if(_projectsDisplay == null) >               { >                    _projectsDisplay = new ProjectsDisplay(this); >                } >                pushScreen(_projectsDisplay); >            } >            else >            { >                 if(_loginScreen == null) >                 { >                    _loginScreen = new LoginScreen(this); >                 } >                 pushScreen(_loginScreen); >            } >         } >        catch ( Exception e ) >        { >            System.out.println( e.toString() ); >        } >    } > > > Please confirm what needs to be changed or if there is another way we should be going about this.  Thank you for your help! > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Search java

February 12, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29