- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 android 中使用 ksoap2 将类作为参数发送到 Web 服务。这是我在 android 中的代码:
public Object simpleConnect() {
SoapObject request = new SoapObject(namespace, methodName);
Foo para = new Foo();
para.setFooId(2333222);
para.setCompanyId(12);
para.setField2(true);
para.setField3(2);
para.setPrimaryKey(765);
para.setUserId(987);
request.addProperty("param", para);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.addMapping(namespace, "Foo", Foo.class);
HttpTransportSE ht = new HttpTransportSE(url);
try {
ht.call(soapAction, envelope);
return envelope.getResponse(); //got error deserialize in this line
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
这是我在服务中尝试调用的方法:
public Foo addObjFoo(Foo param) throws SystemException {
System.out.println("something");
fooPersistence.update(param, false);
return param;
}
这是我的 wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:http.service.test.com" xmlns:intf="urn:http.service.test.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://model.test.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:http.service.test.com">
<!--WSDL created by Apache Axis version: 1.4Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://model.test.com">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="FooSoap">
<sequence>
<element name="companyId" type="xsd:long"/>
<element name="field2" type="xsd:boolean"/>
<element name="field3" type="xsd:int"/>
<element name="fooId" type="xsd:long"/>
<element name="primaryKey" type="xsd:long"/>
<element name="userId" type="xsd:long"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="addFooResponse">
<wsdl:part name="addFooReturn" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="printmessageRequest">
<wsdl:part name="behi" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="addFooRequest">
<wsdl:part name="para" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="printmessageResponse">
<wsdl:part name="printmessageReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="addObjFooResponse">
<wsdl:part name="addObjFooReturn" type="tns1:FooSoap"/>
</wsdl:message>
<wsdl:message name="addObjFooRequest">
<wsdl:part name="param" type="xsd:anyType"/>
</wsdl:message>
<wsdl:portType name="FooServiceSoap">
<wsdl:operation name="addFoo" parameterOrder="para">
<wsdl:input message="impl:addFooRequest" name="addFooRequest"/>
<wsdl:output message="impl:addFooResponse" name="addFooResponse"/>
</wsdl:operation>
<wsdl:operation name="addObjFoo" parameterOrder="param">
<wsdl:input message="impl:addObjFooRequest" name="addObjFooRequest"/>
<wsdl:output message="impl:addObjFooResponse" name="addObjFooResponse"/>
</wsdl:operation>
<wsdl:operation name="printmessage" parameterOrder="behi">
<wsdl:input message="impl:printmessageRequest" name="printmessageRequest"/>
<wsdl:output message="impl:printmessageResponse" name="printmessageResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Plugin_obtice_FooServiceSoapBinding" type="impl:FooServiceSoap">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="addFoo">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="addFooRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:http.service.test.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="addFooResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:http.service.test.com" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="addObjFoo">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="addObjFooRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:http.service.test.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="addObjFooResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:http.service.test.com" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="printmessage">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="printmessageRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:http.service.test.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="printmessageResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:http.service.test.com" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="FooServiceSoapService">
<wsdl:port binding="impl:Plugin_obtice_FooServiceSoapBinding" name="Plugin_obtice_FooService">
<wsdlsoap:address location="http://localhost:8080/WebService-portlet/axis/Plugin_obtice_FooService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
最后这是我在客户端的 Foo 类:
package com.obtice.liferaytest;
import java.util.Hashtable;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
public class Foo implements KvmSerializable {
protected long localCompanyId;
public long getCompanyId() {
return localCompanyId;
}
public void setCompanyId(long param) {
this.localCompanyId = param;
}
protected boolean localField2;
public boolean getField2() {
return localField2;
}
public void setField2(boolean param) {
this.localField2 = param;
}
protected int localField3;
public int getField3() {
return localField3;
}
public void setField3(int param) {
this.localField3 = param;
}
protected long localFooId;
public long getFooId() {
return localFooId;
}
public void setFooId(long param) {
this.localFooId = param;
}
protected long localPrimaryKey;
public long getPrimaryKey() {
return localPrimaryKey;
}
public void setPrimaryKey(long param) {
this.localPrimaryKey = param;
}
protected long localUserId;
public long getUserId() {
return localUserId;
}
public void setUserId(long param) {
this.localUserId = param;
}
@Override
public Object getProperty(int index) {
Object object = null;
switch (index) {
case 0:
object = localCompanyId;
break;
case 1:
object = localField2;
break;
case 2:
object = localField3;
break;
case 3:
object = localFooId;
break;
case 4:
object = localPrimaryKey;
break;
case 5:
object = localUserId;
break;
default:
break;
}
return object;
}
@Override
public int getPropertyCount() {
return 9;
}
@Override
public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
switch (index) {
case 0:
info.name = "companyId" ;
info.type = PropertyInfo.LONG_CLASS ;
break;
case 1:
info.name = "field2";
info.type = PropertyInfo.BOOLEAN_CLASS ;
break;
case 2:
info.name = "field3";
info.type = PropertyInfo.INTEGER_CLASS ;
break;
case 3:
info.name = "fooId";
info.type = PropertyInfo.LONG_CLASS ;
break;
case 4:
info.name = "primaryKey";
info.type = PropertyInfo.LONG_CLASS ;
break;
case 5:
info.name = "userId";
info.type = PropertyInfo.LONG_CLASS ;
break;
default:
break;
}
}
@Override
public void setProperty(int index, Object obj) {
String objStr = obj.toString();
switch (index) {
case 0:
localCompanyId = Long.parseLong(objStr);
break;
case 1:
localField2 = Boolean.parseBoolean(objStr);
break;
case 2:
localField3 = Integer.parseInt(objStr);
break;
case 3:
localFooId = Long.parseLong(objStr);
break;
case 4:
localPrimaryKey = Long.parseLong(objStr);
break;
case 5:
localUserId = Long.parseLong(objStr);
break;
default:
break;
}
}
}
我在调用 Web 服务和响应时遇到了这个错误:
SoapFault - faultcode: 'soapenv:Server.userException' faultstring: 'org.xml.sax.SAXException: Deserializing parameter 'param': could not find deserializer for type {urn:http.service.test.com/}Foo' faultactor: 'null' detail: org.kxml2.kdom.Node@4057bb40
请帮帮我。我完全坚持了下来。
谢谢...
最佳答案
我收到了同样的错误消息,我正在疯狂地试图找出答案。
在传输调用之前添加这一行
androidHttpTransport.debug = true;
通话后的这两个
Log.i(REQUEST, androidHttpTransport.requestDump);
Log.i(RESPONSE, androidHttpTransport.responseDump);
并查看您在信封中发送的 Foo 的类型,并确保它与 WSDL 中声明的类型相匹配。
在我的项目中,原来是包络映射
envelope.addMapping(namespace, "GetFacilityReservations",GetFacilityReservations.class);
将我的自定义类作为类型 n0 发送,因为那是我最初声明的 namespace 的类型。但是我的类(class)是另一种类型。
所以我需要做的就是在我的映射中将命名空间更改为正确的。
envelope.addMapping("urn:XPressLocate", "GetFacilityReservations",GetFacilityReservations.class);
关于android - 在 ksoap2 android 中找不到类型错误的解串器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23803577/
我有一个这样的对象: "choice": { "000": { "id": "001", "label": "test",
我正在使用aerospike的java客户端。我希望更改 aerospike 用于 java 对象的序列化程序,即 java 序列化程序。 我打算使用其他更快的序列化库,例如PROTOSTOFF/AV
我有一个奇怪的问题,我有一个 HashMap,我将其序列化以供以后在磁盘上使用。 这是一个HashMap ConverterMetadata是我编写的用于跟踪音乐文件元数据的自定义类。 Convert
这是我的类(省略 getter 和 setter): public class ClassWithAMap { @JsonProperty("map") @JsonDeserializ
我在 python spark 应用程序中创建了一个 kafka 流,可以解析通过它的任何文本。 kafkaStream = KafkaUtils.createStream(s
我正在尝试将一些 Json 解析为 Java 对象。 有些字段需要自定义行为,所以我尝试在构造函数上使用 @JsonCreator。 好吧,它可以工作,但是对于使用 @JsonProperty 注释的
据我了解,DS.FixtureAdapter 默认情况下不使用序列化器。这是正确的吗? 我主要尝试使用夹具适配器进行自定义转换。我看到 DS.JSONSerializer 调用转换 here 的反序列
我正在使用 etaty rediscala (1.4.2) 连接到 Play 2.4 中的 Redis。我的代码如下: override def getMember(token: String): F
我将事件的有效负载作为 JSON 字符串保存到数据库中。为了在代码中只有一种版本的事件,同时仍然能够读取旧事件,我想在反序列化之前“向上转换”序列化数据。 我想到了这样的事情: public Obje
我正在使用一个总是这样响应的 API: { "stuff_i_need": [ { "title": "Hello" }, { "title":
我是一名优秀的程序员,十分优秀!