我用C#做了一个wcf服务,用的是C#提供的默认的函数,
namespace WCFSolution
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(string value); [OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite); // TODO: 在此添加您的服务操作
} // 使用下面示例中说明的数据协定将复合类型添加到服务操作
[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; }
}
}
}然后运行后,查看http://127.0.0.1:8100/Service1?wsdl里的内容,发现缺少例如:CompositeType的类型定义。这样的话,我用其他开发工具,例如:delphi的webservice导入的时候,发现缺少类型定义。
如下代码:
unit Service1;interfaceuses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;type // ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:GetData - "http://tempuri.org/"
// !:GetDataResponse - "http://tempuri.org/"
// !:GetDataUsingDataContract - "http://tempuri.org/"
// !:GetDataUsingDataContractResponse - "http://tempuri.org/" // ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/IService1/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : BasicHttpBinding_IService1
// service : Service1
// port : BasicHttpBinding_IService1
// URL : http://127.0.0.1:8100/Service1
// ************************************************************************ //
IService1 = interface(IInvokable)
['{33335FCB-4DFB-92EA-D063-AF625AFEE0FC}']
function GetData(const parameters: GetData): GetDataResponse; stdcall;
function GetDataUsingDataContract(const parameters: GetDataUsingDataContract): GetDataUsingDataContractResponse; stdcall;
end;
注意里面的红色字体,我想知道我该配置什么地方,然后再delphi里才能正确显示出类型定义????
namespace WCFSolution
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(string value); [OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite); // TODO: 在此添加您的服务操作
} // 使用下面示例中说明的数据协定将复合类型添加到服务操作
[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; }
}
}
}然后运行后,查看http://127.0.0.1:8100/Service1?wsdl里的内容,发现缺少例如:CompositeType的类型定义。这样的话,我用其他开发工具,例如:delphi的webservice导入的时候,发现缺少类型定义。
如下代码:
unit Service1;interfaceuses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;type // ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:GetData - "http://tempuri.org/"
// !:GetDataResponse - "http://tempuri.org/"
// !:GetDataUsingDataContract - "http://tempuri.org/"
// !:GetDataUsingDataContractResponse - "http://tempuri.org/" // ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/IService1/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : BasicHttpBinding_IService1
// service : Service1
// port : BasicHttpBinding_IService1
// URL : http://127.0.0.1:8100/Service1
// ************************************************************************ //
IService1 = interface(IInvokable)
['{33335FCB-4DFB-92EA-D063-AF625AFEE0FC}']
function GetData(const parameters: GetData): GetDataResponse; stdcall;
function GetDataUsingDataContract(const parameters: GetDataUsingDataContract): GetDataUsingDataContractResponse; stdcall;
end;
注意里面的红色字体,我想知道我该配置什么地方,然后再delphi里才能正确显示出类型定义????
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货