5
我有以下代碼:如何在.NET/ASMX中更改WebService的響應標記名稱?
namespace WebService1
{
[System.Web.Services.WebService(Namespace = "mynamespace",
Name = "ControlModuleService")]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Services.WebServiceBindingAttribute(Name = "ControlModulePort"),
SoapDocumentService(SoapBindingUse.Literal,SoapParameterStyle.Bare)]
public class Service1 : CommandCenter
{
[WebMethod, SoapDocumentMethod(
ResponseElementName = "setConfigurationResponse")]
public setConfigurationResponse setConfiguration(setConfigurationRequest request)
{
return new setConfigurationResponse();
}
}
類型:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(WrapperName = "setConfigurationResponse", WrapperNamespace = "mynamespace", IsWrapped = false)]
public partial class setConfigurationResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "mynamespace", Order = 0)]
[System.Xml.Serialization.XmlElementAttribute("return", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public transaction[] @return;
public setConfigurationResponse()
{
}
public setConfigurationResponse(transaction[] @return)
{
[email protected] = @return;
}
}
生成下面的WSDL:
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="mynamespace">
<s:element name="request" type="tns:setConfigurationRequest" />
<s:complexType name="setConfigurationRequest">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="transactions" type="tns:transaction" />
<s:element minOccurs="1" maxOccurs="1" form="unqualified" name="turnOnMode" type="s:boolean" />
<s:element minOccurs="1" maxOccurs="1" form="unqualified" name="turnOffMode" type="s:boolean" />
</s:sequence>
</s:complexType>
<s:complexType name="transaction">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="idCC" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" form="unqualified" name="idTrans" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" form="unqualified" name="startTime" type="s:long" />
<s:element minOccurs="1" maxOccurs="1" form="unqualified" name="state" type="s:int" />
</s:sequence>
</s:complexType>
<s:element name="setConfigurationResult" type="tns:setConfigurationResponse" />
<s:complexType name="setConfigurationResponse">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="return" type="tns:transaction" />
</s:sequence>
</s:complexType>
...
</s:schema>
</wsdl:types>
爲什麼更改名稱setConfigurationResponse到setconfigurationResult? 我該如何改變它?
將此貼標爲答案! – decyclone 2010-11-25 11:32:42