无法在Eclipse中创建Java Web服务 - 客户端

时间:2014-09-26 14:20:45

标签: java eclipse web-services wsdl axis

添加一些输入:

错误似乎来自WSDL文件。

  

IWAB0399E从WSDL生成Java时出错:java.io.IOException:   错误:缺少节点'unknown'的类型或ref属性       java.io.IOException:错误:缺少节点'unknown'的类型或ref属性

我简化了网络服务,现在我有了这个WDSL文件:WSDL


我正在尝试从我的java程序进行SOAP调用,为此我使用了apache axis1。我的客户端程序如下:

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;

public class Client {

    public Client() {
    }

    public class QueryResult implements java.io.Serializable{

        String type, name, revision, owner, current, description;

        public QueryResult() {
            super();
        }

        public String getType() { return type; }
        public void setType(String s) { type = s; }
        public String getName() { return name; }
        public void setName(String s) { name = s; }
        public String getRevision() { return revision; }
        public void setRevision(String s) { revision = s; }
        public String getOwner() { return owner; }
        public void setOwner(String s) { owner = s; }
        public String getCurrent() { return current; }
        public void setCurrent(String s) { current = s; }
        public String getDescription() { return description; }
        public void setDescription(String s) { description = s; }

      }

    public static void main(String [] args)
    {

        try {

            Service  service = new Service();

            Call call    = (Call) service.createCall();
            call.setTargetEndpointAddress( new java.net.URL(args[0]) );
            call.setOperationName(new QName("urn:Ppap2Service", "evaluateOne"));

            QName qr = new QName("urn:Ppap2Service", "QueryResult");
            BeanSerializerFactory bsf =   new BeanSerializerFactory(QueryResult.class,qr);   // step 2
            BeanDeserializerFactory bdf = new BeanDeserializerFactory(QueryResult.class,qr);  // step 3
            call.registerTypeMapping(QueryResult.class,qr,bsf,bdf);

            // Set the arguments for the call
            call.addParameter("type", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("name", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("revision", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("owner", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("vault", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("where", XMLType.XSD_STRING, ParameterMode.IN);
            call.setReturnType(qr);

            Object[] checkoutParams = new Object[6];
            checkoutParams[0] = args[1];
            checkoutParams[1] = args[2];
            checkoutParams[2] = args[3];
            checkoutParams[3] = args[4];
            checkoutParams[4] = args[5];
            checkoutParams[5] = args[6];

            QueryResult ret = (QueryResult)call.invoke(checkoutParams);

        } catch (Exception e) {

            System.out.println(e.toString());

        }
    }

}

此代码在调用Web服务时给出了此异常:

ERROR - Exception:
org.xml.sax.SAXException: No object was found for class type class Client
org.xml.sax.SAXException: No object was found for class type class Client
    at org.apache.axis.encoding.ConstructorTarget.set(ConstructorTarget.java:97)
    at org.apache.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:249)
    at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:509)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:171)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeserializer.java:154)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    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:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at Client.main(Client.java:164)
Caused by: org.xml.sax.SAXException: No object was found for class type class Client
    at org.apache.axis.encoding.ConstructorTarget.set(ConstructorTarget.java:88)
    ... 16 more
org.xml.sax.SAXException: No object was found for class type class Client
org.xml.sax.SAXException: No object was found for class type class Client

我不明白这是什么问题。 它似乎是一个构造函数错误所以我添加了无参数的Client构造函数,但没有任何改变。

你可以帮忙吗?

谢谢

1 个答案:

答案 0 :(得分:0)

关闭此问题,因为这是由于我工作的应用程序中的Axis 1实现的限制。