我已通过Microsoft WCF Web服务参考提供程序添加了连接服务(参见图片)代理类已成功创建。
然后,当我尝试从这个Web服务执行sample方法(client.TestLanguageAsync()
- 返回字符串)时,我得到null引用异常 - 但我不知道什么是null,因为异常的细节非常差(在图片上看)。下面是代码。
private async void BtnTest_Clicked(object sender, EventArgs e) {
try {
var endpoint = new EndpointAddress("https://f9512056.f95.ficosa.com/WMS/WMSWebService.asmx");
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport) {
Name = "basicHttpBinding",
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647
};
TimeSpan timeout = new TimeSpan(0, 0, 30);
binding.SendTimeout = timeout;
binding.OpenTimeout = timeout;
binding.ReceiveTimeout = timeout;
WMSWebServiceSoapClient client = new WMSWebServiceSoapClient(binding, endpoint);
string text = await client.TestLanguageAsync(); //This causes exception
label.Text = text;
} catch (Exception E) {
label.Text = E.ToString();
}
}
同样在屏幕上看
Adding service reference and exception screen
有什么想法吗?在此先感谢:)