Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
mrampson #1
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
-
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... -
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... -
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... -
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... -
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... -
mrampson #2
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
-
-
healey_mark #4
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
-
mrampson #5
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
-
mrampson #6
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
-
healey_mark #7
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



Reply With Quote

