실제 테스트에서 이상한 것을 흉내 내기위한 작은 테스트 웹 서비스가 있습니다. 데모는 앱과 동일한 동작을 보여 주므로 간결하게 데모를 사용합니다.형식이 WCF 서비스에 노출되지 않음
내 서비스 인터페이스 파일은 다음과 같이 보입니다 (VS2008에서 만든 기본 WCF 서비스 인 것처럼 보이지만 하단에 새로운 공용 메서드 (GetOtherType())와 두 개의 새로운 클래스 (SomeOtherType 및
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace WCFServiceTest
{
public class Service1 : IService1
{
#region IService1 Members
public string GetData(int value)
{
throw new NotImplementedException();
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
throw new NotImplementedException();
}
#endregion
#region IService1 Members
public SomeOtherType GetOtherType()
{
throw new NotImplementedException();
}
#endregion
}
}
내가 가진 문제는 다음과 같이 SomeComplexType). SomeOtherType 유형의 SomeComplexType의 일반적인 목록을 관리
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace WCFServiceTest
{
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
[OperationContract]
SomeOtherType GetOtherType();
}
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
[DataContract]
public class SomeOtherType
{
public List<SomeComplexType> Items { get; set; }
}
[DataContract]
public class SomeComplexType
{
}
}
내 서비스가 구현되었는지 나는 ASP에서이 서비스에 대한 서비스 참조를 포함하는 경우. NET 웹 응용 프로그램, 내가 ca Intellisense를 통해 SomeComplexType을 볼 수 없습니다. 오류가 유형 또는 네임 스페이스와 관련이 없습니다. 그러나 SomeOtherType을 찾을 수 있습니다 (형식이 공용 메서드 중 하나의 반환 형식이라고 가정합니다).
WCF 서비스에서 형식을 공개 메서드 중 하나 (반환 형식 또는 인수)의 메서드 시그니처에 포함하지 않은 경우 해당 형식을 공개 할 수 없다고 생각합니까? 그렇다면 어떻게 클라이언트의 SomeOtherType 인스턴스 안의 Items를 반복 할 수 있습니까?
많은 분들께 감사드립니다.
사이먼
실제로 이상합니다. 데이터 계약과 서비스 자체를 한 곳에서 정의하는 이유는 무엇입니까? 또한 SVC 파일 또는 별도의 .cs 파일에 있습니까? – Slavo