有关Web Service传递复杂类型的问题Web Service中有一些API是接收复杂类型的,我是这样的调用的,但出现了异常.代码和异常如下,希望达人指点.
不知我哪里出错?客户端代码: String wsdlUrl = "http://localhost:8080/axis/services/PersonIdServ?wsdl"; String nameSpaceUri = "urn:PersonIdServ";
Service service = new Service(); Call call = (Call) service.createCall(); QName ariQn = new QName(nameSpaceUri, "BiArithmetic"); call.registerTypeMapping(BiArithmetic.class, ariQn, new BeanSerializerFactory(BiArithmetic.class, ariQn), new BeanDeserializerFactory(BiArithmetic.class, ariQn) ); try { call.setTargetEndpointAddress(new URL(wsdlUrl)); call.setOperationName(new QName(nameSpaceUri,
"createBiArithmetic")); call.addParameter("arg1", ariQn, ParameterMode.IN);
call.setReturnType(XMLType.AXIS_VOID);
BiArithmetic biAri = new BiArithmetic ("1234567", 1);
biAri.setAriData(byteArrayOut.toByteArray());
biAri.setAriName("test");
biAri.setAriSuffix("ari");
biAri.setBaseInd("N");
biAri.setPrimaryInd("Y");
biAri.setFetchLen("9999");
biAri.setUsualInd("Y");
Object obj = call.invoke(new Object[] { biAri});
if (obj != null)
System.out.println(obj.toString()); } catch (Exception e) {
e.printStackTrace(); }布置代码:
<service name="PersonIdServ" provider="java:RPC">        <parameter name="className" value="com.ak.bi.serv.PersonIdServ"/>        <parameter name="allowedMethods" value="*"/>       <beanMapping qname="myNS:BiArithmetic" xmlns:myNS="urn:BiArithmetic" languageSpecificType="java:com.ak.bi.BiArithmetic"/>
 
</service>异常:
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system properly.
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: org.xml.sax.SAXException: No object was found for class type int
 faultActor: 
 faultNode: 
 faultDetail: 
{http://xml.apache.org/axis/}hostname:16391A0688E2477org.xml.sax.SAXException: No object was found for class type int
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.content(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.content(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
at org.apache.crimson.parser.Parser2.parse(Unknown Source)
at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.ak.bi.util.BiPictureClient.main(BiPictureClient.java:105)很明显是客户端出错了,BiArithmetic.class里有一个Field是int类型,其他为String类型.
Ps:如果我传递的是基本类型的话是没问题的.
期待达人指点.

解决方案 »

  1.   


    <schema targetNamespace="urn:BiArithmetic">
    <import namespace="http://bi.ak.com"/>
    <import namespace="http://xml.apache.org/xml-soap"/>
    <import namespace="urn:BiFeature"/>
    <import namespace="urn:BiPicture"/>
    <import namespace="http://localhost:8080/axis/services/PersonIdServ"/>
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

    <complexType name="BiArithmetic">

    <sequence>
    <element name="ariData" nillable="true" type="xsd:base64Binary"/>
    <element name="ariName" nillable="true" type="xsd:string"/>
    <element name="ariSeq" nillable="true" type="xsd:string"/>
    <element name="ariSuffix" nillable="true" type="xsd:string"/>
    <element name="baseInd" nillable="true" type="xsd:string"/>
    <element name="fetchLen" nillable="true" type="xsd:string"/>
    <element name="primaryInd" nillable="true" type="xsd:string"/>
    <element name="usualInd" nillable="true" type="xsd:string"/>
    <element name="verNo" type="xsd:int"/>
    </sequence>
    </complexType>
    </schema>
      

  2.   

    这是其中一部分...
    太长不能贴全部你觉得问题出现在哪?
    org.xml.sax.SAXException: No object was found for class type int 
    这样的异常在网上也找不到相应的解决办法...
    难道要到Axis官方去发Email?
      

  3.   

    其实wsdl中的复杂类型在被解析是生成了java类,包括类的方法和属性,所以对复杂类型的
    处理其实就是对某一个java类的处理,不知道我这么说你能不能理解
      

  4.   

    很多都用Axis啊。我觉得WebService不是让你传递复杂对象用的,那是RMI的事情。总的来说,我觉得不是很可行。
      

  5.   

    但是他应该在服务器端的绑定实现上,如xxxBindingImpl.java在实现中如果参数是一个在wsdl中定义的
    complexType的话,那么这个参数应该是一个对象,而且大部分情况下需要序列化
      

  6.   

    对,WSDL中已经定义了序列化了,不然也不会返回复杂类型了,对吧...做为参数传递也是可以的,只不过出现了上面的异常,当我的复杂类型中有INT时,如果是String的话是可以的.
      

  7.   

    我想问的是int是复杂类型吗,我以前写过这样的wsdl
    如:<xsd:complexType name="Item">
    <xsd:all>
    <xsd:element name="product_id" type="xsd:string"/>
    <xsd:element name="product_name" type="xsd:string"/>
    <xsd:element name="unit_price" type="xsd:float"/>
    <xsd:element name="quantity" type="xsd:int"/>
    <xsd:element name="total_price" type="xsd:float"/>
    <xsd:element name="description" type="xsd:string"/>
    </xsd:all>
    </xsd:complexType>生成的类为Item.javapublic class Item  implements java.io.Serializable {
        private java.lang.String product_id;    private java.lang.String product_name;    private float unit_price;    private int quantity;    private float total_price;    private java.lang.String description;    public Item() {
        }    public Item(
               java.lang.String product_id,
               java.lang.String product_name,
               float unit_price,
               int quantity,
               float total_price,
               java.lang.String description) {
               this.product_id = product_id;
               this.product_name = product_name;
               this.unit_price = unit_price;
               this.quantity = quantity;
               this.total_price = total_price;
               this.description = description;
        }//其中的一部分
      

  8.   

    String有对象 而int没有对应的对象吧
      

  9.   

    是啊,int是基本数据类型,在xml中是内嵌的