Coldfusion error while accessing Java webservice

孤者浪人 提交于 2019-12-08 10:02:36

问题


I created one Java-AXIs2 webservice which returns a java object (user defined class). The I try to access it on coldfusion using this

<cfset wsObj=createobject("webservice","http://localhost:8080/FFMpegHelperServices/services/TranscodeVideoFileFactoryWS?wsdl")>

When I try to access this wsObj and do some operations, I get the following error

Cannot perform web service invocation getTranscodeVideoFile. The fault returned when invoking the web service operation is:<br> <pre>AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:314) at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035) at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165) at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141) at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236) at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384) at org.apache.axis.client.Call.invoke(Call.java:2448) at org.apache.axis.client.Call.invoke(Call.java:2347) at org.apache.axis.clien... ''</pre> <br>The error occurred on line 34. 

Any one has any idea hopw to handle this.

The webservice class looks like this

public class TranscodeVideoFileFactoryWS {

    private TranscodeVideoFile[] temp = new TranscodeVideoFile[1];

    public String getTranscodeVideoFile() {
        return "nasir";
    }

}

I want to access that class being returned.


回答1:


The key to your issue lies hidden within this portion of the error:

No deserializer for

The webservice you're trying to consume is working with custom datatypes; there is a very good chance that the webservice either requires an argument...or returns a value...which is a type of variable that CF does not understand (say, a custom Class).

Unfortunately, to resolve this issue, you'll have to dig a bit deeper into the guts of the webservice, and find out if you can implement those custom types on your end.

-- edit --

Based on the description of your Java Class in the comment, when it is initialized, a private var is instatiated:

private TranscodeVideoFile[] temp = new TranscodeVideoFile[1];

while not directly related to your method call, it is being created as a part your initial CreateObject(), and therefore, is attempting to me maintained in some capacity in the object calls that follow. Unfortunately, that Class is custom and unknown to CF, and will generate a deserializer error if you continue down this development path.

There's a solution...but there is also a "Right Thing" to do in this case.

Solution

Add the compiled classes to the webservice stubs directory by hand, which makes ColdFusion aware of them, so that when you invoke methods on the webservice, ColdFusion knows how to handle the classes, and serialize/deserialize them appropriately.

I used this process a few month while working with the Netsuite API, credit: Jeremy Gibbens. You'll also want to do some research on the ColdFusion tool that allows to produce stubs ad-hoc--the tool is wsdl2java.

Dated article on Wsdl2Java, but relevant nonetheless.

The "Right Thing"

If you can, don't work with custom types over SOAP. If you have control of the code that wraps the FFMpeg Helper objects, and are contributing to the service itself--don't write any code that deals with custom classes. Work with the types that ColdFusion understands.

ColdFusion-compatible datatypes for use in Web Services.



来源:https://stackoverflow.com/questions/8260301/coldfusion-error-while-accessing-java-webservice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!