Webservice and complex data type issue

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Webservice and complex data type issue

    I created a webservice that returned a structure which .Net doesn't seem to
    like. So I created a complex type using component and cfproperty to define it
    and set the returntype of the service to be of the complex type. I create the
    object within the service to be able to return in (obj =
    createObject("component","complexData") for instance) and populate the fields
    in the complex type and then return it. When I try to acccess the web service
    (even from coldfusion), I get the following:

    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXParseException: Premature end of file.
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException:
    Premature end of file.
    at org.apache.xerces.util.ErrorHandlerWrapper.createS AXParseException(Unknown
    Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.fatalEr ror(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determin eDocVersion(Unknown
    Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    a...

    If I change the return type to any and return a string for instance, then
    there doesn't seem to be a problem. It appears to be an issue with the complex
    data type. Any ideas?

    Mike

    mrampson Guest

  2. Similar Questions and Discussions

    1. Consuming Web Service that returns a Complex Data Type
      All, I'm trying to consume a web service that returns a complex data type. I'm not having any luck. Hoping someone can point me in the right...
    2. Webservice data size issue
      Hi, I've created one webservice which is being called from DHTML. I am just passing the required parameters to the webmethods and it returns me a...
    3. How do you pass an complex data types to webservice?
      Hello, I have gone through the simple CFC web services examples where you invoke a call to a web service with a methods and parameters.... but...
    4. Syntax error -- data type issue?
      Hi, I keep getting the following error when testing a page with form to insert record. System.Data.OleDb.OleDbException: Syntax error in...
    5. Referencing web service complex data type within a second web service (like a delegate)
      Hi, I am trying to figure out if ASP.NET XML Web Services and the WSDL standard can handle this type of scenario: I have two web services, and...
  3. #2

    Default Re: Webservice and complex data type issue

    Here is a small recreation of the problem:

    Here is the component type

    <cfcomponent>
    <cfproperty name="status" type="string" hint="Usually SUCCESS or FAIL."
    displayname="status">
    <cfproperty name="code" type="string" hint="Return code from the engine."
    displayname="code">
    <cfproperty name="id" type="string" hint="Unique transaction id."
    displayname="id">
    <cfproperty name="text" type="string" displayname="text">
    </cfcomponent>

    Here is the web service:

    <cfcomponent displayname="TestCCWS" hint="CC Web Services" >
    <cffunction name="CCSale" access="remote" output="no"
    returntype="CCWSResponseStruct" displayname="CCSale">
    <cfset var response = createObject("component","CCWSResponseStruct")>
    <cfset response.status = "good">
    <cfreturn response>
    </cffunction>
    </cfcomponent>

    This works if I call it as a component, but fails as a web service with the
    message from before. If I change the returntype to struct or string and return
    one of those, then everything works ok. This is on version 7.




    mrampson Guest

  4. #3

    Default Re: Webservice and complex data type issue

    bump
    mrampson Guest

  5. #4

    Default Re: Webservice and complex data type issue

    You CAN make this work. I had to experiment.
    Sometimes it seems like CF gets confused if you change the signature of a
    function. I found that deleting the corresponding entries under:
    data and services -> web services
    in the cold fusion administrator is sometimes necessary.

    You should try to surf to the address of the WSDL document:

    http: //my_server/my_webservice.cfc?wsdl

    as you sometimes get better error messages when doing that.

    Also, I sometimes had to write stub functions that explicitly return the
    structured type so that type would appear in the WSDL.
    For example:
    <cfcomponent ...><!---My web service--->
    <cffunction name="newRequestStruc" returntype="RequestStruc" access="remote"
    output="false">
    <cfobject component="RequestStruc" name="returnVal">
    <cfset returnVal.sString = "">
    <cfset returnVal.sNum = 5>
    <cfreturn returnVal>
    </cffunction>
    </cfcomponent>

    Sorry I can't be more explicit, but I had to experiment myself to get it
    working.


    healey_mark Guest

  6. #5

    Default Re: Webservice and complex data type issue

    Instead of deleting the services you can do something like:

    <cfobject type="JAVA"
    action="Create"
    name="factory"
    class="coldfusion.server.ServiceFactory">
    <cfset RpcService = factory.XmlRpcService>
    <cfset RpcService.refreshWebService("http://url/WS.cfc?wsdl")>

    This seems to fix that issue. The wsdl does have the structure in it. If I
    create a function that all it does is create the component structure, fills it
    in, and returns it, I still get the premature end of file. The transfer object
    definition does show up in the wsdl so it isn't that the transfer object
    definition doesn't show up. This has been very frustrating.

    Mike

    mrampson Guest

  7. #6

    Default Re: Webservice and complex data type issue

    Anybody at MM have anything to say about this? I filed a bug report, but
    haven't heard from that either.
    Unfortunately, I'm stuck. Anything else I could try out and post results of?
    This version is up-to-date
    with chf700002.jar.


    mrampson Guest

  8. #7

    Default Re: Webservice and complex data type issue

    This test code works for me:
    I placed the following files in the /webservices folder on my machine (also
    up-to-date mx7)
    Requesting the WSDL works ([url]http://localhost/webservices/ws.cfc?wsdl[/url])
    Requesting [url]http://localhost/webservices/testws.cfm[/url] also works and displays the
    values that were set in the web service.
    I know it's not fully a real-world test (the test file should be on a
    different machine than the web service) but that simplifies the problem.


    <!---ws.cfc--->
    <cfcomponent displayname="Tests">
    <cffunction name="testString" returntype="string" access="remote"
    output="false">
    <cfreturn "gotcha">
    </cffunction>

    <cffunction name="testChecklist" returntype="checklistItem" access="remote"
    output="false">
    <cfobject component="checklistItem" name="theItem">
    <cfset theItem.sItem="checklist item">
    <cfset theItem.sStatus="new status">
    <cfreturn theItem>
    </cffunction>
    </cfcomponent>

    <!---testws.cfm--->
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <cfinvoke
    webservice="http://localhost/webservices/ws.cfc?wsdl"
    method="testChecklist"
    returnvariable="aChecklistitem">
    </cfinvoke>
    <cfoutput>
    #aChecklistItem.sItem#<br>
    #aChecklistItem.sStatus#<br>
    </cfoutput>
    </body>
    </html>

    <!---checklistItem.cfc--->
    <cfcomponent>
    <cfproperty name="sItem" type="string">
    <cfproperty name="sStatus" type="string">
    </cfcomponent>

    healey_mark Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139