2011-11-23 5 views
1

ASP.NET 웹 서비스에서 매개 변수 유형 태그를 제어하는 ​​방법은 무엇입니까? 나는 하나의 웹 응용 프로그램에서 < xml> 문자열 </xml>을 얻고 < 데이터> </data> 다른 것을 제어 할 수있는 방법이 있습니까?ASP.NET 웹 서비스 매개 변수 유형

[WebMethod] 
public bool TestFunction(string xml) 
{ 
    //DO SOMETHING 
    return true; 
} 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <TestFunction xmlns="http://tempuri.org/"> 
     <xml>string</xml> //<data>string</data> 
    </TestFunction> 
    </soap:Body> 
</soap:Envelope> 

편집 : 나는 당신이 지정하는 매개 변수 이름을 사용하여 기능을

답변

3

어떤 방법이 노출의 이름을 변경하는 것을 잊었다. 메서드를 public bool TestFunction(string FooBar)으로 변경하면 문자열은 결과 XML의 <FooBar>string</FooBar> 태그에 포함됩니다.

당신은 WCF를 사용하는 경우는 다른 이름을 사용하는 시리얼 라이저를 지시하는 메시지 계약을 사용하거나 MessageParameter 적용이 동작을 변경할 수 있습니다 : 그러나

public bool TestFunction([MessageParameter(Name="YourName")]string xml) 

을,이 또한 적용 여부를 알 수없는 ASP.Net 웹 서비스.

+0

예 매개 변수 이름 이었기 때문에 이름 때문에 전송 데이터 형식과 관련이 있다고 생각했습니다. – redman