I'm trying to build a webservice with ASP that will be given three parameters: a string, a date/time and another string. After making the method, the wsdl contains this:
我正在尝试使用ASP构建一个Web服务,它将提供三个参数:字符串,日期/时间和另一个字符串。制作方法后,wsdl包含:
<s:element name="TimesheetAudit"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="employeeNumber" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="periodEndDate" type="s:dateTime"/> <s:element minOccurs="0" maxOccurs="1" name="timesheet" type="s:string"/> </s:sequence> </s:complexType> </s:element>
The black box calling my web service is complaining that there is a mismatch in the number of parameters. I am assuming this is because my webmethod is technically taking 1 parameter, a complex type, instead of three.
调用我的网络服务的黑匣子抱怨参数数量不匹配。我假设这是因为我的webmethod在技术上采用了1个参数,一个复杂的类型,而不是三个。
Is this the problem? If so, what can I do to overcome it?
这是问题吗?如果是这样,我该怎么做才能克服它?
Edit: The consumer is the black box in this case, I must mold my web service to match the caller. Adding
编辑:消费者是这种情况下的黑匣子,我必须塑造我的网络服务以匹配来电者。添加
[SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)]
to my method signature gives the following error:
' does not conform to WS-I Basic Profile v1.1. Please examine each of the normative statement violations below. To turn off conformance check set the ConformanceClaims property on corresponding WebServiceBinding attribute to WsiClaims.None.
R2204: A document-literal binding in a DESCRIPTION MUST refer, in each of its soapbind:body element(s), only to wsdl:part element(s) that have been defined using the element attribute.
- Part 'input' of message 'TimesheetAuditSoapIn' from service description with targetNamespace='http://www.netdes.com/'.
- Part 'TimesheetAuditResult' of message 'TimesheetAuditSoapOut' from service description with targetNamespace='http://www.netdes.com/'.
2 个解决方案
#1
It is difficult to be sure without more information about what exactly the client is expecting, but it could be a parameter style issue.
如果没有关于客户期望的具体内容的更多信息,很难确定,但它可能是参数样式问题。
By default, an ASP.NET web service uses the "Wrapped" parameter style, which means that all of the parameters get wrapped in a single element that is sent inside the SOAP body.
默认情况下,ASP.NET Web服务使用“Wrapped”参数样式,这意味着所有参数都包装在SOAP主体内部发送的单个元素中。
You can change the method declaration to use the "Bare" parameter style, which puts all the parameters directly inside the SOAP body, without a wrapper element. This is achieved via the ParameterStyle property on the SoapDocumentMethodAttribute on the web method.
您可以更改方法声明以使用“Bare”参数样式,该样式将所有参数直接放在SOAP正文中,而不使用包装器元素。这是通过Web方法上的SoapDocumentMethodAttribute上的ParameterStyle属性实现的。
See this MSDN entry for details.
有关详细信息,请参阅此MSDN条目。
In response to conformance error: You can disable WS-I conformance checking by putting the following in your web.config:
响应一致性错误:您可以通过在web.config中添加以下内容来禁用WS-I一致性检查:
<configuration>
<system.web>
<webServices>
<conformanceWarnings>
<remove name='BasicProfile1_1'/>
</conformanceWarnings>
</webServices>
</system.web>
</configuration>
Conformance is normally a good thing, but it's not required. Since you aren't in control of the definition in this case, you don't have much of a choice.
一致性通常是一件好事,但并不是必需的。由于在这种情况下您无法控制定义,因此您没有太多选择。
It is also possible that the client is expecting an RPC-style web service instead of a document-style web service. (This would be controlled with a SoapRpcMethodAttribute instead of a SoapDocumentMethodAttribute.) If you still have no luck after turning off the conformance warning you might try changing to RPC-style and see if that works.
客户端也可能期望RPC样式的Web服务而不是文档样式的Web服务。 (这将使用SoapRpcMethodAttribute而不是SoapDocumentMethodAttribute进行控制。)如果在关闭一致性警告后仍然没有运气,则可以尝试更改为RPC样式并查看是否有效。
And if there's any way you can get a definition (either source or, better yet, a WSDL used to produce the source) for the client so that you can tell what exactly it's expecting, it would help. If you can get a WSDL you can have .NET generate the web service method for you in the correct format.
如果有任何方法可以为客户端获取定义(源代码,或者更好的是,用于生成源的WSDL),以便您可以确定它的预期结果,这将有所帮助。如果您可以获得WSDL,则可以让.NET以正确的格式为您生成Web服务方法。
#2
It sounds like you're the one building the web service host, so you get to run the show, right?
听起来你是构建Web服务主机的人,所以你可以运行这个节目吧?
If you can launch Visual Studio, click File, New Website, add a web service to it, use the auto-generated WSDL and successfully connect to it from a test harness, then the consumer of that web service ought to be able to read that same WSDL and connect to it as well as you. The important thing is that you have a test harness that works.
如果您可以启动Visual Studio,请单击“文件”,“新建网站”,向其添加Web服务,使用自动生成的WSDL并从测试工具成功连接到该工具,然后该Web服务的使用者应该能够读取该服务相同的WSDL并连接到它和你。重要的是你有一个有效的测试工具。
If that's the case, then the black box problem lies on their end of the wire, not yours.
如果是这种情况,那么黑匣子的问题就在于它们的末端,而不是你的。
#1
It is difficult to be sure without more information about what exactly the client is expecting, but it could be a parameter style issue.
如果没有关于客户期望的具体内容的更多信息,很难确定,但它可能是参数样式问题。
By default, an ASP.NET web service uses the "Wrapped" parameter style, which means that all of the parameters get wrapped in a single element that is sent inside the SOAP body.
默认情况下,ASP.NET Web服务使用“Wrapped”参数样式,这意味着所有参数都包装在SOAP主体内部发送的单个元素中。
You can change the method declaration to use the "Bare" parameter style, which puts all the parameters directly inside the SOAP body, without a wrapper element. This is achieved via the ParameterStyle property on the SoapDocumentMethodAttribute on the web method.
您可以更改方法声明以使用“Bare”参数样式,该样式将所有参数直接放在SOAP正文中,而不使用包装器元素。这是通过Web方法上的SoapDocumentMethodAttribute上的ParameterStyle属性实现的。
See this MSDN entry for details.
有关详细信息,请参阅此MSDN条目。
In response to conformance error: You can disable WS-I conformance checking by putting the following in your web.config:
响应一致性错误:您可以通过在web.config中添加以下内容来禁用WS-I一致性检查:
<configuration>
<system.web>
<webServices>
<conformanceWarnings>
<remove name='BasicProfile1_1'/>
</conformanceWarnings>
</webServices>
</system.web>
</configuration>
Conformance is normally a good thing, but it's not required. Since you aren't in control of the definition in this case, you don't have much of a choice.
一致性通常是一件好事,但并不是必需的。由于在这种情况下您无法控制定义,因此您没有太多选择。
It is also possible that the client is expecting an RPC-style web service instead of a document-style web service. (This would be controlled with a SoapRpcMethodAttribute instead of a SoapDocumentMethodAttribute.) If you still have no luck after turning off the conformance warning you might try changing to RPC-style and see if that works.
客户端也可能期望RPC样式的Web服务而不是文档样式的Web服务。 (这将使用SoapRpcMethodAttribute而不是SoapDocumentMethodAttribute进行控制。)如果在关闭一致性警告后仍然没有运气,则可以尝试更改为RPC样式并查看是否有效。
And if there's any way you can get a definition (either source or, better yet, a WSDL used to produce the source) for the client so that you can tell what exactly it's expecting, it would help. If you can get a WSDL you can have .NET generate the web service method for you in the correct format.
如果有任何方法可以为客户端获取定义(源代码,或者更好的是,用于生成源的WSDL),以便您可以确定它的预期结果,这将有所帮助。如果您可以获得WSDL,则可以让.NET以正确的格式为您生成Web服务方法。
#2
It sounds like you're the one building the web service host, so you get to run the show, right?
听起来你是构建Web服务主机的人,所以你可以运行这个节目吧?
If you can launch Visual Studio, click File, New Website, add a web service to it, use the auto-generated WSDL and successfully connect to it from a test harness, then the consumer of that web service ought to be able to read that same WSDL and connect to it as well as you. The important thing is that you have a test harness that works.
如果您可以启动Visual Studio,请单击“文件”,“新建网站”,向其添加Web服务,使用自动生成的WSDL并从测试工具成功连接到该工具,然后该Web服务的使用者应该能够读取该服务相同的WSDL并连接到它和你。重要的是你有一个有效的测试工具。
If that's the case, then the black box problem lies on their end of the wire, not yours.
如果是这种情况,那么黑匣子的问题就在于它们的末端,而不是你的。