0
.NET 웹 서비스에 연결하는 응용 프로그램이 있는데 각 웹 서비스 메서드에 대해 동일한 메서드를 만들고 있지만 매개 변수와 웹 서비스가 다르다는 것을 알게되었습니다 방법. 다음 방법으로 매개 변수를 받아들이는 방법을 찾고 있는데, 1 대 몇 가지를 관리하는 것이 더 유용 할 수 있습니다.SOAP 메서드에 매개 변수 전달
현재 방법 * NameSpace, URL, argName, argValue는 모두 클래스 맨 위에 정의됩니다. 나는이되었지만 오류의 점점 많은 서로 다른 시도의 몇 가지를 시도했습니다
public static Document GetTickets(String WebServiceMethod, ArrayList Params) {
try {
SoapObject request = new SoapObject(NameSpace, WebServiceMethod);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
//Syntax is wrong, I know, but just want to show what I'm looking to do:
foreach(Parameter p in Params)
request.addProperty(p[0].value, p[1].value);
envelope.setOutputSoapObject(request);
androidHttpTransport.call("RemoteWebService/" + WebServiceMethod, envelope);
SoapPrimitive responseData = (SoapPrimitive) envelope.getResponse();
if (responseData != null)
{
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation of the XML file
InputSource is = new InputSource(new StringReader(responseData.toString()));
return db.parse(is);
}
else
return null;
}
catch (Exception e)
{
Errors.LogError(e);
return null;
}
}
:
public static Document GetTickets() {
try {
SoapObject request = new SoapObject(NameSpace, "GetTickets");
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
request.addProperty(argName, argValue);
request.addProperty("Customer", "ABC");
request.addProperty("Local", "USA");
envelope.setOutputSoapObject(request);
androidHttpTransport.call("RemoteWebService/GetTickets", envelope);
SoapPrimitive responseData = (SoapPrimitive) envelope.getResponse();
if (responseData != null)
{
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation of the XML file
InputSource is = new InputSource(new StringReader(responseData.toString()));
return db.parse(is);
}
else
return null;
}
catch (Exception e)
{
Errors.LogError(e);
return null;
}
}
나는이 라인을 따라 뭔가 싶습니다. 나는 그것이 다소 단순하다는 것을 알고 있지만 그것을 알아낼 수는 없다.
당신은 오류를 게시 할 수 있습니까? – rodrigoap
글쎄, 내가 말했듯이, 배열, 다차원 배열 및 기타 몇 가지를 시도했지만 범위 오류가 발생했다면 인덱스를 계속 읽었습니다. 이는 액세스되는 요소의 인덱스가 범위 밖에 있다는 것을 의미합니다. 배열의 범위,하지만 난이 모든 것을 삭제하고 처음부터 다시 시작 이걸로 좌절했습니다. 죄송합니다. 오류가 발생하지 않았습니다. – Robert