내 응용 프로그램에서 웹 서비스를 호출하려고합니다. 내가 입력 한 후 잘 작동하지만 같은 문자열 또는 원시를 받아 웹 서비스 메서드를 호출하면 때 복잡한 객체를 허용하는 웹 서비스 메서드 호출 후 나는 다음과 같은 얻을 오류웹 서비스에 복잡한 객체 전달
org.apache.axis2.AxisFault: Unknow type {http://spec.com}specimen
at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:349)
at org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:827)
at org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java:746)
I (내 경우에는 표본 클래스의) 다음입니다 : 내가 웹 서비스 탐색기에서 내 웹 서비스를 테스트하고 그 작업 fine.Here가 여기 내 웹 서비스
package com.spec;
public class Spec {
public String sayHello(String name) // I can successfully invoke this
{
return "Have a great day " + name;
}
public String saveSpecimen(Specimen specimen) // Getting error for this
{
System.out.println("id: " + specimen.getId());
System.out.println("name: " + specimen.getName());
return "Specimend with id " + specimen.getId() + " is successfully saved";
}
}
입니다 http://seesharpgears.blogspot.in/2010/10/ksoap-android-web-service-tutorial-with.html
나의 표본 클래스
입니다 활동에서 6,이package com.ws;
import java.util.Hashtable;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
public class Specimen implements KvmSerializable {
int id;
String name;
public Specimen() {
}
public Specimen(int idValue, String nameValue) {
id = idValue;
name = nameValue;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Object getProperty(int arg0) {
if (arg0 == 0)
return id;
else
return name;
}
public int getPropertyCount() {
// TODO Auto-generated method stub
return 2;
}
public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo info) {
switch (arg0) {
case 0:
info.type = PropertyInfo.INTEGER_CLASS;
info.name = "id";
break;
case 1:
info.type = PropertyInfo.STRING_CLASS;
info.name = "name";
break;
default:
break;
}
}
public void setProperty(int arg0, Object value) {
switch (arg0) {
case 0:
id = Integer.parseInt(value.toString());
break;
case 1:
name = value.toString();
break;
}
}
}
발췌문
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
OPERATION_NAME);
Specimen specimen = new Specimen();
specimen.setId(1);
specimen.setName("Test_Specimen");
PropertyInfo info = new PropertyInfo();
info.setName("specimen");
info.setValue(specimen);
info.setType(specimen.getClass());
request.addProperty(info);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.addMapping(WSDL_TARGET_NAMESPACE, "specimen",new Specimen().getClass());
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
httpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject)envelope.getResponse();
Toast.makeText(getApplicationContext(),"Msg from web servce " + response.toString(),Toast.LENGTH_LONG).show();
나는 문제가 WSDL 파일 내 표본 복합 유형 선언이
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" argetNamespace="http://spec.com/xsd">
<xs:complexType name="Specimen">
<xs:sequence>
<xs:element minOccurs="0" name="id" type="xs:int"/>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/></xs:sequence></xs:complexType>
</xs:schema>
날 경우 알려 주시기 바랍니다 여기
envelope.addMapping(WSDL_TARGET_NAMESPACE, "specimen",new Specimen().getClass());
으로 생각 나는 실수를 저지르고있다.
감사합니다.
대문자로 만드십시오 envelope.addMapping (WSDL_TARGET_NAMESPACE, "Specimen", 새로운 Specimen(). getClass()); 그것이 효과가 있는지보십시오. 나는 잘 모르겠다. – riship89
@ hrishikeshp19 : 행운을 빌어 요. – xyz
여기를 방문하셨습니까?> http://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks#sending/receiving_array_of_complex_types_or_primitives? – OguzOzkeroglu