为什么 svctuil 生成的代理代码这么小?
我正在使用 svcutil 为以下 Web 服务端点生成代理代码 遵循 OGC CSW 2.0.2 (07-006r1) 标准目录服务。
我已经下载了整个OGC架构文件并将它们放入我的“D:/temp/OGCSchemas” /”目录。
我感兴趣的模式是 CSW,但是 CSW 模式包含并导入其他模式,这就是我下载整个集的原因。
我的问题是:为什么生成的代理代码这么小?我不能用它,可以吗?代码生成是否因我收到的错误/警告而中断?
这是我的 svcutil 执行:
C:\Windows\system32>svcutil D:\temp\OGCSchemas\csw\2.0.2\http-binding.wsdl D:\temp\OGCSchemas\csw\2.0.2\xml-interfaces.wsdl D:\tem
p\OGCSchemas\csw\2.0.2\responses.wsdl D:\temp\OGCSchemas\csw\2.0.2\CSW-discovery.xsd D:\temp\OGCSchemas\csw\2.0.2\CSW-publication.
xsd D:\temp\OGCSchemas\ows\1.0.0\owsExceptionReport.xsd D:\temp\OGCSchemas\csw\2.0.2\record.xsd D:\temp\OGCSchemas\ows\1.0.0\owsAl
l.xsd D:\temp\OGCSchemas\filter\1.1.0\filter.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcterms.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcm
es.xsd D:\temp\OGCSchemas\ows\1.0.0\owsGetCapabilities.xsd D:\temp\OGCSchemas\filter\1.1.0\expr.xsd D:\temp\OGCSchemas\filter\1.1.
0\sort.xsd D:\temp\OGCSchemas\filter\1.1.0\filterCapabilities.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryAggregates.xsd D:\temp
\OGCSchemas\ows\1.0.0\owsServiceIdentification.xsd D:\temp\OGCSchemas\ows\1.0.0\owsServiceProvider.xsd D:\temp\OGCSchemas\ows\1.0.
0\owsOperationsMetadata.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryPrimitives.xsd D:\temp\OGCSchemas\ows\1.0.0\owsDataIdentific
ation.xsd D:\temp\OGCSchemas\ows\1.0.0\ows19115subset.xsd D:\temp\OGCSchemas\ows\1.0.0\owsCommon.xsd D:\temp\OGCSchemas\gml\3.1.1\
base\geometryBasic2d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryBasic0d1d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\measures.xsd D:
\temp\OGCSchemas\gml\3.1.1\base\units.xsd D:\temp\OGCSchemas\gml\3.1.1\base\dictionary.xsd D:\temp\OGCSchemas\gml\3.1.1\base\gmlBa
se.xsd D:\temp\OGCSchemas\gml\3.1.1\base\basicTypes.xsd D:\temp\OGCSchemas\xlink\1.0.0\xlinks.xsd /out:D:\temp\ogc.csw.proxy.cs
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
Copyright (c) Microsoft Corporation. All rights reserved.
Error: Cannot import wsdl:binding
Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.opengis.net/cat/csw/2.0.2/http']/wsdl:binding[@name='csw-PO
ST']
Generating files...
D:\temp\ogc.csw.proxy.cs
这是它生成的 ogc.csw.proxy.cs 代理文件。 (非常小)
[assembly: System.Runtime.Serialization.ContractNamespaceAttribute("http://www.opengis.net/ows", ClrNamespace="www.opengis.net.ows")]
namespace www.opengis.net.ows
{
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
[System.Xml.Serialization.XmlRootAttribute(IsNullable=false)]
public partial class ExceptionReport : object, System.Xml.Serialization.IXmlSerializable
{
private System.Xml.XmlNode[] nodesField;
private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("ExceptionReport", "http://www.opengis.net/ows");
public System.Xml.XmlNode[] Nodes
{
get
{
return this.nodesField;
}
set
{
this.nodesField = value;
}
}
public void ReadXml(System.Xml.XmlReader reader)
{
this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);
}
public void WriteXml(System.Xml.XmlWriter writer)
{
System.Runtime.Serialization.XmlSerializableServices.WriteNodes(writer, this.Nodes);
}
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas)
{
System.Runtime.Serialization.XmlSerializableServices.AddDefaultSchema(schemas, typeName);
return typeName;
}
}
}
编辑#1 阅读 Yaron Naveh 的博客后,我意识到 svcutil 不喜欢这种 http 绑定(我猜是这样的) OGC 已指定)。因此,我将 http-binding.wsdl 替换为soap-binding.wsdl,一切正常,没有错误,并且按预期生成了一个巨大的代理文件。
I'm using svcutil to generate proxy code for the following web service endpoint which follows the OGC CSW 2.0.2 (07-006r1) standard for catalog services.
I've downloaded the entire OGC schema files and placed them into my "D:/temp/OGCSchemas/" Directory.
The schema i'm interested in is CSW, however CSW schema includes and imports other schemas and that's why i've downloaded the entire set.
My question is: Why is the proxy code that is generated so small? I can't use that, can it? Was the code generation interrupted by the error/warning i'm getting?
This is my svcutil excecution:
C:\Windows\system32>svcutil D:\temp\OGCSchemas\csw\2.0.2\http-binding.wsdl D:\temp\OGCSchemas\csw\2.0.2\xml-interfaces.wsdl D:\tem
p\OGCSchemas\csw\2.0.2\responses.wsdl D:\temp\OGCSchemas\csw\2.0.2\CSW-discovery.xsd D:\temp\OGCSchemas\csw\2.0.2\CSW-publication.
xsd D:\temp\OGCSchemas\ows\1.0.0\owsExceptionReport.xsd D:\temp\OGCSchemas\csw\2.0.2\record.xsd D:\temp\OGCSchemas\ows\1.0.0\owsAl
l.xsd D:\temp\OGCSchemas\filter\1.1.0\filter.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcterms.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcm
es.xsd D:\temp\OGCSchemas\ows\1.0.0\owsGetCapabilities.xsd D:\temp\OGCSchemas\filter\1.1.0\expr.xsd D:\temp\OGCSchemas\filter\1.1.
0\sort.xsd D:\temp\OGCSchemas\filter\1.1.0\filterCapabilities.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryAggregates.xsd D:\temp
\OGCSchemas\ows\1.0.0\owsServiceIdentification.xsd D:\temp\OGCSchemas\ows\1.0.0\owsServiceProvider.xsd D:\temp\OGCSchemas\ows\1.0.
0\owsOperationsMetadata.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryPrimitives.xsd D:\temp\OGCSchemas\ows\1.0.0\owsDataIdentific
ation.xsd D:\temp\OGCSchemas\ows\1.0.0\ows19115subset.xsd D:\temp\OGCSchemas\ows\1.0.0\owsCommon.xsd D:\temp\OGCSchemas\gml\3.1.1\
base\geometryBasic2d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryBasic0d1d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\measures.xsd D:
\temp\OGCSchemas\gml\3.1.1\base\units.xsd D:\temp\OGCSchemas\gml\3.1.1\base\dictionary.xsd D:\temp\OGCSchemas\gml\3.1.1\base\gmlBa
se.xsd D:\temp\OGCSchemas\gml\3.1.1\base\basicTypes.xsd D:\temp\OGCSchemas\xlink\1.0.0\xlinks.xsd /out:D:\temp\ogc.csw.proxy.cs
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
Copyright (c) Microsoft Corporation. All rights reserved.
Error: Cannot import wsdl:binding
Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.opengis.net/cat/csw/2.0.2/http']/wsdl:binding[@name='csw-PO
ST']
Generating files...
D:\temp\ogc.csw.proxy.cs
And this is the ogc.csw.proxy.cs proxy file it's generating. (VERY SMALL)
[assembly: System.Runtime.Serialization.ContractNamespaceAttribute("http://www.opengis.net/ows", ClrNamespace="www.opengis.net.ows")]
namespace www.opengis.net.ows
{
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
[System.Xml.Serialization.XmlRootAttribute(IsNullable=false)]
public partial class ExceptionReport : object, System.Xml.Serialization.IXmlSerializable
{
private System.Xml.XmlNode[] nodesField;
private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("ExceptionReport", "http://www.opengis.net/ows");
public System.Xml.XmlNode[] Nodes
{
get
{
return this.nodesField;
}
set
{
this.nodesField = value;
}
}
public void ReadXml(System.Xml.XmlReader reader)
{
this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);
}
public void WriteXml(System.Xml.XmlWriter writer)
{
System.Runtime.Serialization.XmlSerializableServices.WriteNodes(writer, this.Nodes);
}
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas)
{
System.Runtime.Serialization.XmlSerializableServices.AddDefaultSchema(schemas, typeName);
return typeName;
}
}
}
EDIT #1
After reading Yaron Naveh's blog i realized svcutil does not like this http-binding (i guess the way the OGC has it specified). So i replaced the http-binding.wsdl for the soap-binding.wsdl and everything works without errors and a HUGE proxy file is generate as expected.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有同样的问题。我的 WSDL 不包含 XSD 导入,并且有 3 个绑定:Http、Soap11 和 Soap12。删除 HttpBinding 解决了问题。
此外,使用 XmlSerialized 没有帮助。
I had the same problem. My WSDL contained no XSD imports and had 3 bindings: Http, Soap11 and Soap12. Removing the HttpBinding solved the problem.
Aditionally, using the XmlSerialized didn't help.