ServiceDescription/ServiceDescriptionImporter 클래스를 사용하여 웹 서비스를 동적으로 호출합니다. 나는 WSDL 설명에 깊은 조금 파고 웹 방법WSDL의 ServiceDescription/Proxy
2) 모든 웹 방법의 각 매개 변수의 실제 유형/구성 (즉, 경우 각
1) 파라미터 정보를 좀하고 싶습니다
public static object CallWebService(string webServiceAsmx, string serviceName, string methodName, object[] args = null)
{
WebClient client = new WebClient();
Stream stream = client.OpenRead(webServiceAsmx + "?wsdl");
ServiceDescription description = ServiceDescription.Read(stream);
ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
importer.ProtocolName = "Soap12";
importer.AddServiceDescription(description, null, null);
importer.Style = ServiceDescriptionImportStyle.Client;
importer.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties;
하십시오의 WebMethod 가능하면, 내가 여기
내가 동적 호출에 대해 가지고있는 코드), 그것뿐만 아니라 구성되어 원시/다른 유형을 알 필요가 매개 변수로 일부 복잡한 형식을 사용합니다
나는 b까지 찾아 낼 수 있었다. 메소드 이름, 매개 변수 정보와 같은 기본 정보. 그러나 더 자세한 분석이 필요합니다. 예를 들어 Wsdl.exe가 프록시 클래스에서 생성하는 모든 정보에 액세스해야하지만 Wsdl.exe를 실행하고 정보를 동적으로 검색해야합니다. 모든 메서드에 대해 반환 형식이 무엇인지, 매개 변수가 구성되어 있는지 등을 알아야합니다. 프로그래밍 방식으로 추출하는 방법을 WSDL에서 알고 있습니다. 필자가 조사한 수업 중 일부는 다음과 같습니다.
ServiceDescription.Description
ServiceDescription.Messages
ServiceDescription.Types
많은 사람들이 비어있는 것처럼 보입니다.
미리 감사드립니다. 내가 조금 더 가지고
는 편집이 내가 통과하려고 XML 스키마 (WSDL)입니다 :
- <s:complexType name="Session">
- <s:complexContent mixed="false">
- <s:extension base="tns:EntityObject">
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Host" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SessionType" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="LoginTime" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="LogoutTime" type="s:dateTime" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
을 그리고 이것은 통과하는 코드입니다 :
foreach (System.Xml.Schema.XmlSchemaComplexType item in xmlSchema.SchemaTypes.Values)
{
if (item != null)
{
System.Xml.Schema.XmlSchemaParticle particle = item.Particle;
System.Xml.Schema.XmlSchemaSequence sequence = particle as System.Xml.Schema.XmlSchemaSequence;
if (sequence != null)
{
foreach (System.Xml.Schema.XmlSchemaElement childElement in sequence.Items)
{
string name = childElement.Name;
string type = childElement.SchemaTypeName.Name;
Console.WriteLine(name + " " + type);
}
}
}
이것은 조금 더 나아졌지만 ComplexType의 complexContent를 얻는 것에는 미치지 않습니다.
세션 세션
Sean, 재미있는 코드로 보입니다. 마음에 들지 않으면 전체 코드를 공유 할 수 있으면 고맙겠습니다. 나는 같은 것을 구현하려고 노력했지만 많은 어려움을 겪었다. 위 코드에서는 매개 변수, 설명 및 ComplexParameter가 무엇인지 알 수 없습니다. 도와주세요! –