思科 MSE API:SOAP通信与Android应用程序

3
我希望您能够告诉我如何在Android源代码中应用SOAP-Request参数。以下是示例:
问题1:这是否正确? (<--)
private static final String SOAP_ACTION = "           "; <-- ???
private static final String METHOD_NAME = "GetStationStats "; <-- Is this right?
private static final String NAMESPACE = " http://cisco/mse/location"; <-- Is this right?
private static final String URL = "https://192.168.100.231/location"; <-- Is this right?

Q2. 从SOAP-XML更改

<AesBusinessSession id="10510"/>      
<AesMobileStation macAddress="00:01:02:03:04:05"/> 

=> 转换到Android源代码

request.addProperty("AesBusinessSession id" ,10510);    <-- Is this right?
request.addProperty("AesMobileStation macAddress" ,00:01:02:03:04:05);    <-- Is this right?

这是我的源代码。

private void soapData(String searchData) {
SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);        
Log.e("dd", "Soap Created");        
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);        
envelope.dotNet=true;        
envelope.setOutputSoapObject(request);
request.addProperty("SQL" ,searchData);
HttpTransportSE androidHttpTransport=new HttpTransportSE(URL);
androidHttpTransport.debug = true;
 try       
{            
   androidHttpTransport.call(SOAP_ACTION, envelope);           
   SoapPrimitive result = (SoapPrimitive)envelope.getResponse();            //String result1 = xmlPasing(result.toString()); //xml파싱           
   String re_xml = result.toString();            
   outPut.setText(re_xml); //결과값 출력       
} 
catch(Exception e)       
{           
   Log.e("dd", "Soap Catch",e);            
   e.printStackTrace();       
} //try-catch    
}

==================================================== 示例 方法:GetStationStats

根据不同的搜索条件,返回存储在MSE中的AesMobileStation统计记录。结果:一个AesBaseStats对象或null(如果未找到)。参数:AesBusinessSession、AesMobileStation Key

7.3.1 SOAP请求

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">   
<SOAP-ENV:Body>    
<GetStationStats xmlns=” http://cisco.com/mse/location”>       
<AesBusinessSession id="10510"/>      
<AesMobileStation macAddress="00:01:02:03:04:05"/>     
</GetStationStats>   
</SOAP-ENV:Body>
 </SOAP-ENV:Envelope> 

7.3.2 SOAP响应 7.3.2.1 成功

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">   
<SOAP-ENV:Body>    
<Response xmlns=” http://cisco.com/mse/location”>       
<AesBaseStats  macAddress="00:01:02:03:04:05" packetsSent=”12” bytesSent=”1221111” packetsRecv=”1111” bytesRecv=”1212204” policyErrors=”0” changedOn=”1220324324”/>    
</Response>  
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> 

============================================================

1个回答

0

SOAP_ACTION - 你可以在wsdl中看到它,可能是这样的:"http://cisco/mse/location/GetStationStats"METHOD_NAMENAMESPACE似乎是正确的。 URL - 服务url,我不知道它是否正确。你也可以在wsdl中看到它。

request.addProperty("AesBusinessSession id" ,10510);
request.addProperty("AesMobileStation macAddress" ,00:01:02:03:04:05);

这是错误的(输出将会像这样:<AesBusinessSession id>10510</AesBusinessSession id>)。 您可以使用SoapObjectSoapPrimitive来添加属性:

SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject aesBusinessSession = new SoapObject(NAMESPACE, "AesBusinessSession");
aesBusinessSession.addAttribute("id",10510); 
SoapObject aesBaseStats = new SoapObject(NAMESPACE, "AesBaseStats");  
...//add attrs to aesBaseStats 
request.addSoapObject(aesBusinessSession);
request.addSoapObject(aesBaseStats);

谢谢您的建议。但是,我无法调用addSoapObject。 - user2666348

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接