android 调用C#编写的web server

gavin_jin 发布于 2013/12/18 16:50
阅读 1K+
收藏 0

我使用android连接webService.,使用Soap解析,设置参数如下

private static final String NAMESPACE = "http://tempuri.org/";

private static String URL ="http://soap5.cyclelution.com/CyclelutionWcfService/CyclelutionService.svc";


private static final String METHOD_NAME = "ExportOfficeList";
private static String SOAP_ACTION = NAMESPACE + "ExportOfficeList";


出现下面异常,

SoapFault - faultcode: 'a:ActionNotSupported' faultstring: 'The message with Action 'http://tempuri.org/ExportOfficeList' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).' faultactor: 'null' detail: null

源代码如下:

public class Main extends Activity
{

private static final String NAMESPACE = "http://tempuri.org/";


private static String URL = "http://soap5.cyclelution.com/CyclelutionWcfService/CyclelutionService.svc";

private static final String METHOD_NAME = "ExportOfficeList";
private static String SOAP_ACTION = NAMESPACE + "ExportOfficeList";


public void getWeather()
{
try
{
new Thread()
{
public void run()
{
SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);


rpc.addProperty("CYLClientID", "86");
rpc.addProperty("UserName", "VTGAdmin");
rpc.addProperty("Password", "$%vtg876");
rpc.addProperty("SourceSystemName", "WSI");
rpc.addProperty("SourceSystemVersion", "1.0");


HttpTransportSE ht = new HttpTransportSE(URL);


ht.debug = true;
// 3.设置Soap的请求信息,参数部分为Soap协议的版本号,这里要低于服务器版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);


envelope.bodyOut = rpc;
envelope.dotNet = true;


envelope.setOutputSoapObject(rpc);


try
{
ht.call(SOAP_ACTION, envelope);


} catch (IOException e)
{
e.printStackTrace();
} catch (XmlPullParserException e)
{

String sssString = e.getMessage();
Log.v("gavin", sssString);
e.printStackTrace();
}
SoapFault fault = (SoapFault) envelope.bodyIn;
String faultcode = fault.faultcode;
//
SoapObject result = (SoapObject) envelope.bodyIn;
detail = (SoapObject) result.getProperty("CyclelutionWcfService");
// SoapFault - faultcode: 'a:ActionNotSupported'
// faultstring: 'The message with Action
// 'http://tempuri.org/ExportOfficeList' cannot be processed
// at the receiver, due to a ContractFilter mismatch at the
// EndpointDispatcher. This may be because of either a
// contract mismatch (mismatched Actions between sender and
// receiver) or a binding/security mismatch between the
// sender and the receiver. Check that sender and receiver
// have the same contract and the same binding (including
// security requirements, e.g. Message, Transport, None).'
// faultactor: 'null' detail: null


}
}.start();
return;
} catch (Exception e)
{
e.printStackTrace();
}
}


private String weatherToday;
private String weatherTomorrow;
private String weatherAfterday;
private String weatherCurrent;


private int iconToday[] = new int[2];
private int iconTomorrow[] = new int[2];
private int iconAfterday[] = new int[2];


private Button okButton;
private EditText textInput;
private ImageView imageView1;
private ImageView imageView2;
private TextView textWeatherToday;
private ImageView imageView3;
private ImageView imageView4;
private TextView textWeatherTomorrow;
private ImageView imageView5;
private ImageView imageView6;
private TextView textWeatherAfterday;
private TextView textWeatherCurrent;
private SoapObject detail;


@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


textInput = (EditText) findViewById(R.id.TextWeather);
okButton = (Button) findViewById(R.id.WeatherSearch);
imageView1 = (ImageView) findViewById(R.id.ImageView01);
imageView2 = (ImageView) findViewById(R.id.ImageView02);


textWeatherToday = (TextView) findViewById(R.id.WeatherToday);
imageView3 = (ImageView) findViewById(R.id.ImageView03);
imageView4 = (ImageView) findViewById(R.id.ImageView04);


textWeatherTomorrow = (TextView) findViewById(R.id.WeatherTomorrow);
imageView5 = (ImageView) findViewById(R.id.ImageView05);
imageView6 = (ImageView) findViewById(R.id.ImageView06);


textWeatherAfterday = (TextView) findViewById(R.id.WeatherAfterday);
textWeatherCurrent = (TextView) findViewById(R.id.WeatherCurrent);


okButton.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
showWeather();
// test3();
}
});
}


private void showWeather()
{


getWeather();
}
}
请问高手:问题出现在哪里?

加载中
返回顶部
顶部