그래서 웹 서비스에 연결해야하는 Android 앱을 개발하고 있습니다. 이 연결은 정상적으로 작동합니다. "Hello Christian"을 반환하는 간단한 메서드를 사용하여 테스트했습니다. 이것은 응용 프로그램에서 올바른 표시됩니다. 매개 변수 (이름)를 사용하여이 작업을 수행하려고하면 "Hello null"이 반환됩니다.KSOAP 및 웹 서버 통신 (PropertyInfo)
기술적으로 저는 Android 4.2.2 및 KSOAP 2.6.5를 사용하고 있습니다. 웹 서비스는 Oracle WebLogic v12에서 실행됩니다. 내 소스 코드를 다음 :
private final String NAMESPACE_Local = "http://test.com/";
private final String URL_Local = "http://168.185.226.69:7001/neuesProjekt/neuerWebServiceService";
private final String SOAP_ACTION_Local = "Hello_Action_Name";
private final String METHOD_NAME_Local = "helloname";
private final String URL_Local = "http://168.185.226.21:7001/myTest/myTestWebServiceService";
private final String SOAP_ACTION_Local = "Hello_Action_Extend";
private final String METHOD_NAME_Local = "hello_extend";
public void LocalServer(View view)
{
TextView text = (TextView) findViewById(R.id.update_text);
SoapObject request = new SoapObject(NAMESPACE_Local, METHOD_NAME_Local);
// request.addProperty("name", "Christian");
// String name = "Christian";
//
// PropertyInfo nameProp =new PropertyInfo();
// nameProp.name = "name";
// nameProp.type = String.class;
// nameProp.namespace = NAMESPACE_Local;
// nameProp.setValue(name);
// request.addProperty(nameProp);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL_Local);
try {
androidHttpTransport.call(SOAP_ACTION_Local, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
Log.i("myApp", response.toString());
text.setText(response.toString());
} catch (Exception e) {
Toast.makeText(this,"Device or service offline",Toast.LENGTH_LONG).show();
}
}
나는 두 가지 방법으로 propertyInfo를 추가하려고했습니다. 먼저 간단한 request.addProperty와 PropertyInfo를 작성하고 나중에 추가하는 방법이 있습니다. 두 방법 모두 작동하지 않습니다. 그러나 자습서 (예 : 화씨에서 섭씨로)를 사용하여 서버를 시험해 볼 때 작동하고 적절한 답을 반환합니다. 여기
웹 서버에서 '코드'
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.6hudson-86 svn-revision#12773. -->
<definitions targetNamespace="http://test.com/" name="myTestWebServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://test.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<types>
<xsd:schema>
<xsd:import namespace="http://test.com/" schemaLocation="myTestWebServiceService_schema1.xsd"/>
</xsd:schema>
</types>
<message name="hello">
<part name="parameters" element="tns:hello"/>
</message>
<message name="helloResponse">
<part name="parameters" element="tns:helloResponse"/>
</message>
<portType name="myTestWebService">
<operation name="hello">
<input wsam:Action="Hello_Action" message="tns:hello"/>
<output wsam:Action="http://test.com/myTestWebService/helloResponse" message="tns:helloResponse"/>
</operation>
</portType>
<binding name="myTestWebServicePortBinding" type="tns:myTestWebService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="hello">
<soap:operation soapAction="Hello_Action"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="myTestWebServiceService">
<port name="myTestWebServicePort" binding="tns:myTestWebServicePortBinding">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
</port>
</service>
</definitions>
그래서 난 당신이 중 하나가 있기 때문에 나를 도울 수 있기를 바랍니다
: 그것은 내 문제를 해결하는 데 도움을 준다 경우 WSDL 파일에 따라package com.test;
import javax.jws.*;
@WebService
public class myTestWebService {
@WebMethod(action="Hello_Action")
public String hello() {
return "hello";
}
@WebMethod(action="Hello_Action_Extend")
public String hello_extend(String name)
{
return "hello "+name;
}
}
나는 무엇을 해야할지 전혀 모른다. 친절한 답변, 크리스챤