110,530
社区成员
发帖
与我相关
我的任务
分享
public string GetData(int value, [System.Xml.Serialization.XmlIgnoreAttribute()] bool valueSpecified)
MessageHeaders messageHeaderCollection = OperationContext.Current.IncomingMessageHeaders;
<system.serviceModel>
<services>
<service name="TestWebReferenceOfWCF.Service1" behaviorConfiguration="TestWebReferenceOfWCF.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" contract="TestWebReferenceOfWCF.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TestWebReferenceOfWCF.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
// NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
}
private void button1_Click(object sender, EventArgs e)
{
Service1.Service1 client = new testclient.Service1.Service1();
string res = client.GetData(100, true);
MessageBox.Show(res);
string res2 = client.GetData(100, false);
MessageBox.Show(res2);
Service1.CompositeType para = new testclient.Service1.CompositeType();
para.StringValue = "aaa";
para.BoolValue = false;
para.BoolValueSpecified = true;
Service1.CompositeType res1 = client.GetDataUsingDataContract(para);
MessageBox.Show(res1.StringValue + " -- " + res1.BoolValueSpecified + " --- " + res1.BoolValue);
}
// CODEGEN: The optional WSDL extension element 'PolicyReference' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
// CODEGEN: The optional WSDL extension element 'EndpointReference' from namespace 'http://www.w3.org/2005/08/addressing' was not handled.
air.DomesticAirline x = new air.DomesticAirline();
string test="Adfasd";
DataSet result = x.getDomesticAirlinesTime(test, test, test, test);