I do not want my web method name as part of the hierarchy in my XML. I strictly want the object that was passed in to be encapsulated in a SOAP envelope, then have an empty Header, and in the Body I want the first sub-element to be of the type of object I'm passing in (in this case, ns:QueryRequest).
我不希望我的Web方法名称作为XML中层次结构的一部分。我严格地希望传入的对象封装在SOAP信封中,然后有一个空的Header,而在Body中我希望第一个子元素是我传入的对象类型(在这种情况下) ,ns:QueryRequest)。
When I had an .asmx web page, I was getting two extra levels in my hierarchy (i.e., the web method name and the name of the object being passed into the web method). So, beneath Body, I had GetData -> actualData -> ns:QueryRequest. I was able to suppress the first two elements by creating a [SoapDocumentMethod] on the web method and setting ParameterStyle=SoapParameterStyle.Bare.
当我有一个.asmx网页时,我在我的层次结构中获得了两个额外的级别(即,Web方法名称和传递给Web方法的对象的名称)。所以,在Body下面,我有GetData - > actualData - > ns:QueryRequest。我能够通过在Web方法上创建[SoapDocumentMethod]并设置ParameterStyle = SoapParameterStyle.Bare来抑制前两个元素。
I'm creating a WCF web page now for a comparison. I specified [XmlSerializerFormat] beneath [OperationContract] on the interface and this resolved my namespace issues. I tried implementing [WebInvoke] and [WebGet] beneath that, with a BodyStyle=WebMessageBodyStyle.Bare, but it isn't suppressing the GetData method name in the interface. I need the first element beneath Body to be ns:QueryRequest and not GetData.
我现在正在创建一个WCF网页进行比较。我在界面上的[OperationContract]下面指定了[XmlSerializerFormat],这解决了我的命名空间问题。我尝试使用BodyStyle = WebMessageBodyStyle.Bare在其下实现[WebInvoke]和[WebGet],但它并没有在界面中抑制GetData方法名称。我需要Body下面的第一个元素是ns:QueryRequest而不是GetData。
How can I accomplish this?
我怎么能做到这一点?
1 个解决方案
#1
0
You define a [MessageContract(IsWrapped=false)] for the input parameter and a separate one for the output. This will suppress the unwanted root element.
您为输入参数定义[MessageContract(IsWrapped = false)],并为输出定义单独的一个。这将抑制不需要的根元素。
#1
0
You define a [MessageContract(IsWrapped=false)] for the input parameter and a separate one for the output. This will suppress the unwanted root element.
您为输入参数定义[MessageContract(IsWrapped = false)],并为输出定义单独的一个。这将抑制不需要的根元素。