WCF,转换成WSDL后,里面缺少类型定义?请解答
我用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;
interface
uses 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里才能正确显示出类型定义???? --------------------编程问答-------------------- 这种跨语言了 不如用XML 或干脆BYTE[] 自行封装 解封 --------------------编程问答-------------------- 遇到这种觉得有意思但自己又不会的问题时,总是习惯性的把这句话粘贴进来,帮楼主顶起来 --------------------编程问答-------------------- 这个问题我已经找到答案了,英文注释我少看了一句话,不过codegear公司那个导入工具确实不怎么样,还不支持有状态的会话连接。
补充:.NET技术 , C#