public new string Url { get { return base.Url; } set { if ((((this.IsLocalFileSystemWebService(base.Url) == true) && (this.useDefaultCredentialsSetExplicitly == false)) && (this.IsLocalFileSystemWebService(value) == false))) { base.UseDefaultCredentials = false; } base.Url = value; } }
public new bool UseDefaultCredentials { get { return base.UseDefaultCredentials; } set { base.UseDefaultCredentials = value; this.useDefaultCredentialsSetExplicitly = true; } }
/// <res/> public event getPriceCompletedEventHandler getPriceCompleted;
/// <res/> public event getGreetingCompletedEventHandler getGreetingCompleted;
/// <res/> [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:getPrice", RequestNamespace="http://ws.apache.org/axis2", ResponseNamespace="http://ws.apache.org/axis2", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public void getPrice([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out int @return, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlIgnoreAttribute()] out bool returnSpecified) { object[] results = this.Invoke("getPrice", new object[0]); @return = ((int)(results[0])); returnSpecified = ((bool)(results[1])); }
/// <res/> public void getPriceAsync() { this.getPriceAsync(null); }
/// <res/> public void getPriceAsync(object userState) { if ((this.getPriceOperationCompleted == null)) { this.getPriceOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetPriceOperationCompleted); } this.InvokeAsync("getPrice", new object[0], this.getPriceOperationCompleted, userState); }
还有一个问题
你写的不是webserice吧
谢谢你的回复。
1.按照你说的试了,还是提示同样的错误。以下是getPrice的源码:
public void getPrice([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out int @return, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlIgnoreAttribute()] out bool returnSpecified) {
object[] results = this.Invoke("getPrice", new object[0]);
@return = ((int)(results[0]));
returnSpecified = ((bool)(results[1]));
}2.为什么我写的不是webservice???
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.1022
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------//
// 此源代码是由 Microsoft.VSDesigner 4.0.30319.1022 版自动生成。
//
#pragma warning disable 1591namespace WebApplication.WebService {
using System;
using System.Web.Services;
using System.Diagnostics;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Xml.Serialization;
/// <res/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="SimpleServiceSoap11Binding", Namespace="http://ws.apache.org/axis2")]
public partial class SimpleService : System.Web.Services.Protocols.SoapHttpClientProtocol {
private System.Threading.SendOrPostCallback getPriceOperationCompleted;
private System.Threading.SendOrPostCallback getGreetingOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <res/>
public SimpleService() {
this.Url = global::WebApplication.Properties.Settings.Default.WebApplication_WebService_SimpleService;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
}
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
}
}
/// <res/>
public event getPriceCompletedEventHandler getPriceCompleted;
/// <res/>
public event getGreetingCompletedEventHandler getGreetingCompleted;
/// <res/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:getPrice", RequestNamespace="http://ws.apache.org/axis2", ResponseNamespace="http://ws.apache.org/axis2", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void getPrice([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] out int @return, [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlIgnoreAttribute()] out bool returnSpecified) {
object[] results = this.Invoke("getPrice", new object[0]);
@return = ((int)(results[0]));
returnSpecified = ((bool)(results[1]));
}
/// <res/>
public void getPriceAsync() {
this.getPriceAsync(null);
}
/// <res/>
public void getPriceAsync(object userState) {
if ((this.getPriceOperationCompleted == null)) {
this.getPriceOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetPriceOperationCompleted);
}
this.InvokeAsync("getPrice", new object[0], this.getPriceOperationCompleted, userState);
}
private void OngetPriceOperationCompleted(object arg) {
if ((this.getPriceCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.getPriceCompleted(this, new getPriceCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <res/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:getGreeting", RequestNamespace="http://ws.apache.org/axis2", ResponseNamespace="http://ws.apache.org/axis2", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
public string getGreeting([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] string name) {
object[] results = this.Invoke("getGreeting", new object[] {
name});
return ((string)(results[0]));
}
/// <res/>
public void getGreetingAsync(string name) {
this.getGreetingAsync(name, null);
}
/// <res/>
public void getGreetingAsync(string name, object userState) {
if ((this.getGreetingOperationCompleted == null)) {
this.getGreetingOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetGreetingOperationCompleted);
}
this.InvokeAsync("getGreeting", new object[] {
name}, this.getGreetingOperationCompleted, userState);
}
private void OngetGreetingOperationCompleted(object arg) {
if ((this.getGreetingCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.getGreetingCompleted(this, new getGreetingCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <res/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
}
private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
}
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
}
return false;
}
}
/// <res/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
public delegate void getPriceCompletedEventHandler(object sender, getPriceCompletedEventArgs e);
/// <res/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class getPriceCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal getPriceCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <res/>
public int @return {
get {
this.RaiseExceptionIfNecessary();
return ((int)(this.results[0]));
}
}
/// <res/>
public bool returnSpecified {
get {
this.RaiseExceptionIfNecessary();
return ((bool)(this.results[1]));
}
}
}
/// <res/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
public delegate void getGreetingCompletedEventHandler(object sender, getGreetingCompletedEventArgs e);
/// <res/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class getGreetingCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal getGreetingCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <res/>
public string Result {
get {
this.RaiseExceptionIfNecessary();
return ((string)(this.results[0]));
}
}
}
}#pragma warning restore 1591