SoapServices クラス
アセンブリ: mscorlib (mscorlib.dll 内)



SoapServices クラスのメンバを使用して、Type オブジェクトと XML 型の間で変換を行う方法を次のコード例に示します。
using System; using System.Runtime.Remoting; namespace ExampleNamespace { [System.Runtime.Remoting.Metadata.SoapTypeAttribute( XmlElementName="ExampleClassElementName", XmlNamespace="http://example.org/ExampleXmlNamespace" , XmlTypeName="ExampleXmlTypeName", XmlTypeNamespace="http://example.org/ExampleXmlTypeNamespace")] public class ExampleClass { // A field that will be serialized as an XML element. [System.Runtime.Remoting.Metadata.SoapField( XmlElementName="ExampleFieldElementName", XmlNamespace="http://example.org/ExampleFieldNamespace")] public string ExampleFieldUsingElement; // A field that will be serialized as an XML attribute. [System.Runtime.Remoting.Metadata.SoapField( XmlElementName="ExampleFieldAttributeName", XmlNamespace="http://example.org/ExampleAttributeNamespace" , UseAttribute=true)] public string ExampleFieldUsingAttribute; [System.Runtime.Remoting.Metadata.SoapMethod( SoapAction="http://example.org/ExampleSoapAction#GetHello")] public string GetHello(string name) { return "Hello, " + name; } } } public class Demo { [System.Security.Permissions.SecurityPermissionAttribute( System.Security.Permissions.SecurityAction.LinkDemand, Flags=System.Security.Permissions.SecurityPermissionFlag.Infrastructure)] public static void Main(string[] args) { // Convert a CLR namespace and assembly name into an XML namespace. string xmlNamespace = SoapServices.CodeXmlNamespaceForClrTypeNamespace( "ExampleNamespace", "AssemblyName"); Console.WriteLine("The name of the XML namespace is {0}.", xmlNamespace); // Extract a CLR namespace and assembly name from an XML namespace. string typeNamespace; string assemblyName; SoapServices.DecodeXmlNamespaceForClrTypeNamespace(xmlNamespace, out typeNamespace, out assemblyName); Console.WriteLine("The name of the CLR namespace is {0}.", typeNamespace); Console.WriteLine("The name of the CLR assembly is {0}.", assemblyName); // Get the XML element name and the XML namespace for // an Interop type. string xmlElement; bool isSoapTypeAttribute = SoapServices.GetXmlElementForInteropType( typeof(ExampleNamespace.ExampleClass), out xmlElement, out xmlNamespace); // Print whether the requested value was flagged // with a SoapTypeAttribute. if (isSoapTypeAttribute) { Console.WriteLine( "The requested value was flagged " + "with the SoapTypeAttribute."); } else { Console.WriteLine( "The requested value was not flagged " + "with the SoapTypeAttribute."); } // Print the XML element and the XML namespace. Console.WriteLine( "The XML element for the type " + "ExampleNamespace.ExampleClass is {0}.", xmlElement); Console.WriteLine( "The XML namespace for the type " + "ExampleNamespace.ExampleClass is {0}.", xmlNamespace); // Get the XML type name and the XML type namespace for // an Interop type. string xmlTypeName; string xmlTypeNamespace; isSoapTypeAttribute = SoapServices.GetXmlTypeForInteropType( typeof(ExampleNamespace.ExampleClass), out xmlTypeName, out xmlTypeNamespace); // Print whether the requested value was flagged // with a SoapTypeAttribute. if (isSoapTypeAttribute) { Console.WriteLine( "The requested value was flagged " + "with the SoapTypeAttribute."); } else { Console.WriteLine( "The requested value was not flagged " + "with the SoapTypeAttribute."); } // Print the XML type name and the XML type namespace. Console.WriteLine( "The XML type for the type " + "ExampleNamespace.ExampleClass is {0}.", xmlTypeName); Console.WriteLine( "The XML type namespace for the type " + "ExampleNamespace.ExampleClass is {0}.", xmlTypeNamespace); // Print the XML namespace for a method invocation and its // response. System.Reflection.MethodBase getHelloMethod = typeof(ExampleNamespace.ExampleClass).GetMethod("GetHello"); string methodCallXmlNamespace = SoapServices.GetXmlNamespaceForMethodCall(getHelloMethod); string methodResponseXmlNamespace = SoapServices.GetXmlNamespaceForMethodResponse(getHelloMethod); Console.WriteLine( "The XML namespace for the invocation of the method " + "GetHello in ExampleClass is {0}.", methodResponseXmlNamespace); Console.WriteLine( "The XML namespace for the response of the method " + "GetHello in ExampleClass is {0}.", methodCallXmlNamespace); // Determine whether an XML namespace represents a CLR namespace. string clrNamespace = SoapServices.XmlNsForClrType; if (SoapServices.IsClrTypeNamespace(clrNamespace)) { Console.WriteLine( "The namespace {0} is a CLR namespace." , clrNamespace); } else { Console.WriteLine( "The namespace {0} is not a CLR namespace." , clrNamespace); } // Print the XML namespace for the CLR types. Console.WriteLine( "The XML namespace for the CLR types " + "is {0}.", SoapServices.XmlNsForClrType); // Print the XML namespace for the CLR types // that have an assembly but no common language runtime namespace. Console.WriteLine( "The XML namespace for the CLR types " + "that have an assembly but no namespace, is {0}." , SoapServices.XmlNsForClrTypeWithAssembly); // Print the XML namespace for the CLR types // that are a part of the Mscorlib.dll. Console.WriteLine( "The XML namespace for the CLR types " + "that are part of the Mscorlib.dll, is {0}.", SoapServices.XmlNsForClrTypeWithNs); // Print the XML namespace for the CLR types // that have both an assembly and a common language runtime // namespace. Console.WriteLine( "The XML namespace for the CLR types " + "that have both an assembly and a namespace, is {0}.", SoapServices.XmlNsForClrTypeWithNsAndAssembly); // Get the SOAP action for the method. System.Reflection.MethodBase getHelloMethodBase = typeof(ExampleNamespace.ExampleClass).GetMethod("GetHello"); string getHelloSoapAction = SoapServices.GetSoapActionFromMethodBase(getHelloMethodBase); Console.WriteLine( "The SOAP action for the method " + "ExampleClass.GetHello is {0}.", getHelloSoapAction); bool isSoapActionValid = SoapServices.IsSoapActionValidForMethodBase( getHelloSoapAction, getHelloMethodBase); if (isSoapActionValid) { Console.WriteLine( "The SOAP action, {0}, " + "is valid for ExampleClass.GetHello", getHelloSoapAction); } else { Console.WriteLine( "The SOAP action, {0}, " + "is not valid for ExampleClass.GetHello", getHelloSoapAction); } // Register the SOAP action for the GetHello method. SoapServices.RegisterSoapActionForMethodBase(getHelloMethodBase); // Get the type and the method names encoded into the SOAP action. string encodedTypeName; string encodedMethodName; SoapServices.GetTypeAndMethodNameFromSoapAction( getHelloSoapAction, out encodedTypeName, out encodedMethodName); Console.WriteLine( "The type name encoded in this SOAP action is {0}.", encodedTypeName); Console.WriteLine( "The method name encoded in this SOAP action is {0}.", encodedMethodName); // Get the name and the type of the field using its XML // element name and its XML namespace. For this query to work , // the containing type must be preloaded, and the XML element // name and the XML namespace must be explicitly declared on // the field using a SoapFieldAttribute. // Preload the containing type. SoapServices.PreLoad(typeof(ExampleNamespace.ExampleClass)); // Get the name and the type of a field that will be // serialized as an XML element. Type containingType = typeof(ExampleNamespace.ExampleClass); string xmlElementNamespace = "http://example.org/ExampleFieldNamespace"; string xmlElementName = "ExampleFieldElementName"; Type fieldType; string fieldName; SoapServices.GetInteropFieldTypeAndNameFromXmlElement( containingType, xmlElementName, xmlElementNamespace, out fieldType, out fieldName); Console.WriteLine( "The type of the field is {0}.", fieldType); Console.WriteLine( "The name of the field is {0}.", fieldName); // Get the name and the type of a field that will be // serialized as an XML attribute. string xmlAttributeNamespace = "http://example.org/ExampleAttributeNamespace"; string xmlAttributeName = "ExampleFieldAttributeName"; SoapServices.GetInteropFieldTypeAndNameFromXmlAttribute( containingType, xmlAttributeName, xmlAttributeNamespace, out fieldType, out fieldName); Console.WriteLine( "The type of the field is {0}.", fieldType); Console.WriteLine( "The name of the field is {0}.", fieldName); string interopTypeXmlElementName = "ExampleClassElementName"; string interopTypeXmlNamespace = "http://example.org/ExampleXmlNamespace"; Type interopType = SoapServices.GetInteropTypeFromXmlElement( interopTypeXmlElementName, interopTypeXmlNamespace); Console.WriteLine("The interop type is {0}.", interopType); string interopTypeXmlTypeName = "ExampleXmlTypeName"; string interopTypeXmlTypeNamespace = "http://example.org/ExampleXmlTypeNamespace"; interopType = SoapServices.GetInteropTypeFromXmlType( interopTypeXmlTypeName, interopTypeXmlTypeNamespace); Console.WriteLine("The interop type is {0}.", interopType); // Get the method base object for the GetHello method. System.Reflection.MethodBase methodBase = typeof(ExampleNamespace.ExampleClass).GetMethod("GetHello"); // Print its current SOAP action. Console.WriteLine( "The SOAP action for the method " + "ExampleClass.GetHello is {0}.", SoapServices.GetSoapActionFromMethodBase(methodBase)); // Set the SOAP action of the GetHello method to a new value. string newSoapAction = "http://example.org/ExampleSoapAction#NewSoapAction"; SoapServices.RegisterSoapActionForMethodBase( methodBase, newSoapAction); Console.WriteLine( "The SOAP action for the method " + "ExampleClass.GetHello is {0}.", SoapServices.GetSoapActionFromMethodBase(methodBase)); // Reset the SOAP action of the GetHello method to its default // value, which is determined using its SoapMethod attribute. SoapServices.RegisterSoapActionForMethodBase(methodBase); Console.WriteLine( "The SOAP action for the method " + "ExampleClass.GetHello is {0}.", SoapServices.GetSoapActionFromMethodBase(methodBase)); // Register all types in the assembly with the SoapType attribute. System.Reflection.Assembly executingAssembly = System.Reflection.Assembly.GetExecutingAssembly(); SoapServices.PreLoad(executingAssembly); // Register a specific type with the SoapType attribute. Type exampleType = typeof(ExampleNamespace.ExampleClass); SoapServices.PreLoad(exampleType); // Get the currently registered type for the given XML element // and namespace. string registeredXmlElementName = "ExampleClassElementName"; string registeredXmlNamespace = "http://example.org/ExampleXmlNamespace"; Type registeredType = SoapServices.GetInteropTypeFromXmlElement( registeredXmlElementName, registeredXmlNamespace); Console.WriteLine( "The registered interop type is {0}.", registeredType); // Register a new type for the XML element and namespace. SoapServices.RegisterInteropXmlElement( registeredXmlElementName, registeredXmlNamespace, typeof(String)); // Get the currently registered type for the given XML element // and namespace. registeredType = SoapServices.GetInteropTypeFromXmlElement( registeredXmlElementName, registeredXmlNamespace); Console.WriteLine( "The registered interop type is {0}.", registeredType); // Get the currently registered type for the given XML element // and namespace. string registeredXmlTypeName = "ExampleXmlTypeName"; string registeredXmlTypeNamespace = "http://example.org/ExampleXmlTypeNamespace"; registeredType = SoapServices.GetInteropTypeFromXmlType( registeredXmlTypeName, registeredXmlTypeNamespace); Console.WriteLine( "The registered interop type is {0}.", registeredType); // Register a new type for the XML element and namespace. SoapServices.RegisterInteropXmlType( registeredXmlTypeName, registeredXmlTypeNamespace, typeof(String)); // Get the currently registered type for the given XML element // and namespace. registeredType = SoapServices.GetInteropTypeFromXmlType( registeredXmlTypeName, registeredXmlTypeNamespace); Console.WriteLine( "The registered interop type is {0}.", registeredType); } }
#using <System.Runtime.Remoting.dll> using namespace System; using namespace System::Runtime::Remoting; namespace ExampleNamespace { [System::Runtime::Remoting::Metadata::SoapTypeAttribute( XmlElementName="ExampleClassElementName", XmlNamespace="http://example.org/ExampleXmlNamespace", XmlTypeName="ExampleXmlTypeName", XmlTypeNamespace="http://example.org/ExampleXmlTypeNamespace")] public ref class ExampleClass { public: // A field that will be serialized as an XML element. [System::Runtime::Remoting::Metadata::SoapField( XmlElementName="ExampleFieldElementName", XmlNamespace="http://example.org/ExampleFieldNamespace")] String^ ExampleFieldUsingElement; // A field that will be serialized as an XML attribute. [System::Runtime::Remoting::Metadata::SoapField( XmlElementName="ExampleFieldAttributeName", XmlNamespace="http://example.org/ExampleAttributeNamespace" , UseAttribute=true)] String^ ExampleFieldUsingAttribute; [System::Runtime::Remoting::Metadata::SoapMethod( SoapAction="http://example.org/ExampleSoapAction#GetHello")] String^ GetHello( String^ name ) { return String::Format( L"Hello, {0}", name ); } }; } [System::Security::Permissions::SecurityPermissionAttribute( System::Security::Permissions::SecurityAction::LinkDemand, Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] int main() { // Convert a CLR namespace and assembly name into an XML namespace. String^ xmlNamespace = SoapServices::CodeXmlNamespaceForClrTypeNamespace( L"ExampleNamespace", L"AssemblyName" ); Console::WriteLine( L"The name of the XML namespace is {0}.", xmlNamespace ); // Extract a CLR namespace and assembly name from an XML namespace. String^ typeNamespace; String^ assemblyName; SoapServices::DecodeXmlNamespaceForClrTypeNamespace( xmlNamespace,typeNamespace,assemblyName ); Console::WriteLine( L"The name of the CLR namespace is {0}.", typeNamespace ); Console::WriteLine( L"The name of the CLR assembly is {0}.", assemblyName ); // Get the XML element name and the XML namespace for // an Interop type. String^ xmlElement; bool isSoapTypeAttribute = SoapServices::GetXmlElementForInteropType( ExampleNamespace::ExampleClass::typeid,xmlElement,xmlNamespace ); // Print whether the requested value was flagged // with a SoapTypeAttribute. if ( isSoapTypeAttribute ) { Console::WriteLine( L"The requested value was flagged " L"with the SoapTypeAttribute." ); } else { Console::WriteLine( L"The requested value was not flagged " L"with the SoapTypeAttribute." ); } // Print the XML element and the XML namespace. Console::WriteLine( L"The XML element for the type " L"ExampleNamespace.ExampleClass is {0}.", xmlElement ); Console::WriteLine( L"The XML namespace for the type " L"ExampleNamespace.ExampleClass is {0}.", xmlNamespace ); // Get the XML type name and the XML type namespace for // an Interop type. String^ xmlTypeName; String^ xmlTypeNamespace; isSoapTypeAttribute = SoapServices::GetXmlTypeForInteropType( ExampleNamespace::ExampleClass::typeid,xmlTypeName,xmlTypeNamespace ); // Print whether the requested value was flagged // with a SoapTypeAttribute. if ( isSoapTypeAttribute ) { Console::WriteLine( L"The requested value was flagged " L"with the SoapTypeAttribute." ); } else { Console::WriteLine( L"The requested value was not flagged " L"with the SoapTypeAttribute." ); } // Print the XML type name and the XML type namespace. Console::WriteLine( L"The XML type for the type " L"ExampleNamespace.ExampleClass is {0}.", xmlTypeName ); Console::WriteLine( L"The XML type namespace for the type " L"ExampleNamespace.ExampleClass is {0}.", xmlTypeNamespace ); // Print the XML namespace for a method invocation and its // response. System::Reflection::MethodBase^ getHelloMethod = ExampleNamespace::ExampleClass::typeid->GetMethod( L"GetHello" ); String^ methodCallXmlNamespace = SoapServices::GetXmlNamespaceForMethodCall( getHelloMethod ); String^ methodResponseXmlNamespace = SoapServices::GetXmlNamespaceForMethodResponse( getHelloMethod ); Console::WriteLine( L"The XML namespace for the invocation of the method " L"GetHello in ExampleClass is {0}.", methodResponseXmlNamespace ); Console::WriteLine( L"The XML namespace for the response of the method " L"GetHello in ExampleClass is {0}.", methodCallXmlNamespace ); // Determine whether an XML namespace represents a CLR namespace. String^ clrNamespace = SoapServices::XmlNsForClrType; if ( SoapServices::IsClrTypeNamespace( clrNamespace ) ) { Console::WriteLine( L"The namespace {0} is a CLR namespace." , clrNamespace ); } else { Console::WriteLine( L"The namespace {0} is not a CLR namespace.", clrNamespace ); } // Print the XML namespace for the CLR types. Console::WriteLine( L"The XML namespace for the CLR types " L"is {0}.", SoapServices::XmlNsForClrType ); // Print the XML namespace for the CLR types // that have an assembly but no common language runtime namespace. Console::WriteLine( L"The XML namespace for the CLR types " L"that have an assembly but no namespace, is {0}." , SoapServices::XmlNsForClrTypeWithAssembly ); // Print the XML namespace for the CLR types // that are a part of the Mscorlib.dll. Console::WriteLine( L"The XML namespace for the CLR types " L"that are part of the Mscorlib.dll, is {0}.", SoapServices::XmlNsForClrTypeWithNs ); // Print the XML namespace for the CLR types // that have both an assembly and a common language runtime // namespace. Console::WriteLine( L"The XML namespace for the CLR types " L"that have both an assembly and a namespace, is {0}." , SoapServices::XmlNsForClrTypeWithNsAndAssembly ); // Get the SOAP action for the method. System::Reflection::MethodBase^ getHelloMethodBase = ExampleNamespace::ExampleClass::typeid->GetMethod( L"GetHello" ); String^ getHelloSoapAction = SoapServices::GetSoapActionFromMethodBase( getHelloMethodBase ); Console::WriteLine( L"The SOAP action for the method " L"ExampleClass.GetHello is {0}.", getHelloSoapAction ); bool isSoapActionValid = SoapServices::IsSoapActionValidForMethodBase( getHelloSoapAction, getHelloMethodBase ); if ( isSoapActionValid ) { Console::WriteLine( L"The SOAP action, {0}, " L"is valid for ExampleClass.GetHello", getHelloSoapAction ); } else { Console::WriteLine( L"The SOAP action, {0}, " L"is not valid for ExampleClass.GetHello", getHelloSoapAction ); } // Register the SOAP action for the GetHello method. SoapServices::RegisterSoapActionForMethodBase( getHelloMethodBase ); // Get the type and the method names encoded into the SOAP action. String^ encodedTypeName; String^ encodedMethodName; SoapServices::GetTypeAndMethodNameFromSoapAction( getHelloSoapAction,encodedTypeName,encodedMethodName ); Console::WriteLine( L"The type name encoded in this SOAP action is {0}.", encodedTypeName ); Console::WriteLine( L"The method name encoded in this SOAP action is {0}.", encodedMethodName ); // Get the name and the type of the field using its XML // element name and its XML namespace. For this query to work, // the containing type must be preloaded, and the XML element // name and the XML namespace must be explicitly declared on // the field using a SoapFieldAttribute. // Preload the containing type. SoapServices::PreLoad( ExampleNamespace::ExampleClass::typeid ); // Get the name and the type of a field that will be // serialized as an XML element. Type^ containingType = ExampleNamespace::ExampleClass::typeid; String^ xmlElementNamespace = L"http://example.org/ExampleFieldNamespace"; String^ xmlElementName = L"ExampleFieldElementName"; Type^ fieldType; String^ fieldName; SoapServices::GetInteropFieldTypeAndNameFromXmlElement( containingType,xmlElementName,xmlElementNamespace,fieldType,fieldName ); Console::WriteLine( L"The type of the field is {0}.", fieldType ); Console::WriteLine( L"The name of the field is {0}.", fieldName ); // Get the name and the type of a field that will be // serialized as an XML attribute. String^ xmlAttributeNamespace = L"http://example.org/ExampleAttributeNamespace"; String^ xmlAttributeName = L"ExampleFieldAttributeName"; SoapServices::GetInteropFieldTypeAndNameFromXmlAttribute( containingType,xmlAttributeName,xmlAttributeNamespace,fieldType,fieldName ); Console::WriteLine( L"The type of the field is {0}.", fieldType ); Console::WriteLine( L"The name of the field is {0}.", fieldName ); String^ interopTypeXmlElementName = L"ExampleClassElementName"; String^ interopTypeXmlNamespace = L"http://example.org/ExampleXmlNamespace"; Type^ interopType = SoapServices::GetInteropTypeFromXmlElement( interopTypeXmlElementName, interopTypeXmlNamespace ); Console::WriteLine( L"The interop type is {0}.", interopType ); String^ interopTypeXmlTypeName = L"ExampleXmlTypeName"; String^ interopTypeXmlTypeNamespace = L"http://example.org/ExampleXmlTypeNamespace"; interopType = SoapServices::GetInteropTypeFromXmlType( interopTypeXmlTypeName,interopTypeXmlTypeNamespace ); Console::WriteLine( L"The interop type is {0}.", interopType ); // Get the method base object for the GetHello method. System::Reflection::MethodBase^ methodBase = ExampleNamespace::ExampleClass::typeid->GetMethod( L"GetHello" ); // Print its current SOAP action. Console::WriteLine( L"The SOAP action for the method " L"ExampleClass.GetHello is {0}.", SoapServices::GetSoapActionFromMethodBase( methodBase ) ); // Set the SOAP action of the GetHello method to a new value. String^ newSoapAction = L"http://example.org/ExampleSoapAction#NewSoapAction"; SoapServices::RegisterSoapActionForMethodBase( methodBase, newSoapAction ); Console::WriteLine( L"The SOAP action for the method " L"ExampleClass.GetHello is {0}.", SoapServices::GetSoapActionFromMethodBase( methodBase ) ); // Reset the SOAP action of the GetHello method to its default // value, which is determined using its SoapMethod attribute. SoapServices::RegisterSoapActionForMethodBase( methodBase ); Console::WriteLine( L"The SOAP action for the method " L"ExampleClass.GetHello is {0}.", SoapServices::GetSoapActionFromMethodBase( methodBase ) ); // Register all types in the assembly with the SoapType attribute. System::Reflection::Assembly^ executingAssembly = System::Reflection::Assembly::GetExecutingAssembly(); SoapServices::PreLoad( executingAssembly ); // Register a specific type with the SoapType attribute. Type^ exampleType = ExampleNamespace::ExampleClass::typeid; SoapServices::PreLoad( exampleType ); // Get the currently registered type for the given XML element // and namespace. String^ registeredXmlElementName = L"ExampleClassElementName"; String^ registeredXmlNamespace = L"http://example.org/ExampleXmlNamespace"; Type^ registeredType = SoapServices::GetInteropTypeFromXmlElement( registeredXmlElementName, registeredXmlNamespace ); Console::WriteLine( L"The registered interop type is {0}.", registeredType ); // Register a new type for the XML element and namespace. SoapServices::RegisterInteropXmlElement( registeredXmlElementName,registeredXmlNamespace,String::typeid ); // Get the currently registered type for the given XML element // and namespace. registeredType = SoapServices::GetInteropTypeFromXmlElement( registeredXmlElementName,registeredXmlNamespace ); Console::WriteLine( L"The registered interop type is {0}.", registeredType ); // Get the currently registered type for the given XML element // and namespace. String^ registeredXmlTypeName = L"ExampleXmlTypeName"; String^ registeredXmlTypeNamespace = L"http://example.org/ExampleXmlTypeNamespace"; registeredType = SoapServices::GetInteropTypeFromXmlType( registeredXmlTypeName, registeredXmlTypeNamespace ); Console::WriteLine( L"The registered interop type is {0}.", registeredType ); // Register a new type for the XML element and namespace. SoapServices::RegisterInteropXmlType( registeredXmlTypeName, registeredXmlTypeNamespace,String::typeid ); // Get the currently registered type for the given XML element // and namespace. registeredType = SoapServices::GetInteropTypeFromXmlType( registeredXmlTypeName,registeredXmlTypeNamespace ); Console::WriteLine( L"The registered interop type is {0}.", registeredType ); }
import System.*; import System.Runtime.Remoting.*; /** @attribute System.Runtime.Remoting.Metadata.SoapTypeAttribute( XmlElementName = "ExampleClassElementName", XmlNamespace = "http://example.org/ExampleXmlNamespace", XmlTypeName = "ExampleXmlTypeName", XmlTypeNamespace = "http://example.org/ExampleXmlTypeNamespace") */ public class ExampleClass { // A field that will be serialized as an XML element. /** @attribute System.Runtime.Remoting.Metadata.SoapField( XmlElementName = "ExampleFieldElementName", XmlNamespace = "http://example.org/ExampleFieldNamespace") */ public String exampleFieldUsingElement; // A field that will be serialized as an XML attribute. /** @attribute System.Runtime.Remoting.Metadata.SoapField( XmlElementName = "ExampleFieldAttributeName", XmlNamespace = "http://example.org/ExampleAttributeNamespace", UseAttribute = true) */ public String exampleFieldUsingAttribute; /** @attribute System.Runtime.Remoting.Metadata.SoapMethod( SoapAction = "http://example.org/ExampleSoapAction#GetHello") */ public String GetHello(String name) { return "Hello, " + name; } //GetHello } //ExampleClass public class Demo { /** @attribute System.Security.Permissions.SecurityPermissionAttribute( System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag. Infrastructure) */ public static void main(String[] args) { // Convert a CLR namespace and assembly name into an XML namespace. String xmlNamespace = SoapServices.CodeXmlNamespaceForClrTypeNamespace( "ExampleNamespace", "AssemblyName"); Console.WriteLine("The name of the XML namespace is {0}.", xmlNamespace); // Extract a CLR namespace and assembly name from an XML namespace. String typeNamespace = ""; String assemblyName = ""; SoapServices.DecodeXmlNamespaceForClrTypeNamespace(xmlNamespace, typeNamespace, assemblyName); Console.WriteLine("The name of the CLR namespace is {0}.", typeNamespace); Console.WriteLine("The name of the CLR assembly is {0}.", assemblyName); // Get the XML element name and the XML namespace for // an Interop type. String xmlElement = ""; boolean isSoapTypeAttribute = SoapServices.GetXmlElementForInteropType( ExampleNamespace.ExampleClass.class.ToType(), xmlElement, xmlNamespace); // Print whether the requested value was flagged // with a SoapTypeAttribute. if (isSoapTypeAttribute) { Console.WriteLine("The requested value was flagged " + "with the SoapTypeAttribute."); } else { Console.WriteLine("The requested value was not flagged " + "with the SoapTypeAttribute."); } // Print the XML element and the XML namespace. Console.WriteLine("The XML element for the type " + "ExampleNamespace.ExampleClass is {0}.", xmlElement); Console.WriteLine("The XML namespace for the type " + "ExampleNamespace.ExampleClass is {0}.", xmlNamespace); // Get the XML type name and the XML type namespace for // an Interop type. String xmlTypeName = ""; String xmlTypeNamespace = ""; isSoapTypeAttribute = SoapServices.GetXmlTypeForInteropType( ExampleNamespace.ExampleClass.class.ToType(), xmlTypeName, xmlTypeNamespace); // Print whether the requested value was flagged // with a SoapTypeAttribute. if (isSoapTypeAttribute) { Console.WriteLine("The requested value was flagged " + "with the SoapTypeAttribute."); } else { Console.WriteLine("The requested value was not flagged " + "with the SoapTypeAttribute."); } // Print the XML type name and the XML type namespace. Console.WriteLine("The XML type for the type " + "ExampleNamespace.ExampleClass is {0}.", xmlTypeName); Console.WriteLine("The XML type namespace for the type " + "ExampleNamespace.ExampleClass is {0}.", xmlTypeNamespace); // Print the XML namespace for a method invocation and its // response. System.Reflection.MethodBase getHelloMethod = ExampleNamespace. ExampleClass.class.ToType().GetMethod("GetHello"); String methodCallXmlNamespace = SoapServices. GetXmlNamespaceForMethodCall(getHelloMethod); String methodResponseXmlNamespace = SoapServices. GetXmlNamespaceForMethodResponse(getHelloMethod); Console.WriteLine("The XML namespace for the invocation of the method " + "GetHello in ExampleClass is {0}.", methodResponseXmlNamespace); Console.WriteLine("The XML namespace for the response of the method " + "GetHello in ExampleClass is {0}.", methodCallXmlNamespace); // Determine whether an XML namespace represents a CLR namespace. String clrNamespace = SoapServices.get_XmlNsForClrType(); if (SoapServices.IsClrTypeNamespace(clrNamespace)) { Console.WriteLine("The namespace {0} is a CLR namespace.", clrNamespace); } else { Console.WriteLine("The namespace {0} is not a CLR namespace.", clrNamespace); } // Print the XML namespace for the CLR types. Console.WriteLine("The XML namespace for the CLR types " + "is {0}.", SoapServices.get_XmlNsForClrType()); // Print the XML namespace for the CLR types // that have an assembly but no common language runtime namespace. Console.WriteLine("The XML namespace for the CLR types " + "that have an assembly but no namespace, is {0}.", SoapServices.get_XmlNsForClrTypeWithAssembly()); // Print the XML namespace for the CLR types // that are a part of the Mscorlib.dll. Console.WriteLine("The XML namespace for the CLR types " + "that are part of the Mscorlib.dll, is {0}.", SoapServices.get_XmlNsForClrTypeWithNs()); // Print the XML namespace for the CLR types // that have both an assembly and a common language runtime // namespace. Console.WriteLine("The XML namespace for the CLR types " + "that have both an assembly and a namespace, is {0}.", SoapServices.get_XmlNsForClrTypeWithNsAndAssembly()); // Get the SOAP action for the method. System.Reflection.MethodBase getHelloMethodBase = ExampleNamespace. ExampleClass.class.ToType().GetMethod("GetHello"); String getHelloSoapAction = SoapServices. GetSoapActionFromMethodBase(getHelloMethodBase); Console.WriteLine("The SOAP action for the method " + "ExampleClass.GetHello is {0}.", getHelloSoapAction); boolean isSoapActionValid = SoapServices. IsSoapActionValidForMethodBase(getHelloSoapAction, getHelloMethodBase); if (isSoapActionValid) { Console.WriteLine("The SOAP action, {0}, " + "is valid for ExampleClass.GetHello", getHelloSoapAction); } else { Console.WriteLine("The SOAP action, {0}, " + "is not valid for ExampleClass.GetHello", getHelloSoapAction); } // Register the SOAP action for the GetHello method. SoapServices.RegisterSoapActionForMethodBase(getHelloMethodBase); // Get the type and the method names encoded into the SOAP action. String encodedTypeName = ""; String encodedMethodName = ""; SoapServices.GetTypeAndMethodNameFromSoapAction(getHelloSoapAction, encodedTypeName, encodedMethodName); Console.WriteLine("The type name encoded in this SOAP action is {0}.", encodedTypeName); Console.WriteLine("The method name encoded in this SOAP action is {0}.", encodedMethodName); // Get the name and the type of the field using its XML // element name and its XML namespace. For this query to work , // the containing type must be preloaded, and the XML element // name and the XML namespace must be explicitly declared on // the field using a SoapFieldAttribute. // Preload the containing type. SoapServices.PreLoad(ExampleNamespace.ExampleClass.class.ToType()); // Get the name and the type of a field that will be // serialized as an XML element. Type containingType = ExampleNamespace.ExampleClass.class.ToType(); String xmlElementNamespace = "http://example.org/ExampleFieldNamespace"; String xmlElementName = "ExampleFieldElementName"; Type fieldType = null; String fieldName = ""; SoapServices.GetInteropFieldTypeAndNameFromXmlElement(containingType, xmlElementName, xmlElementNamespace, fieldType, fieldName); Console.WriteLine("The type of the field is {0}.", fieldType); Console.WriteLine("The name of the field is {0}.", fieldName); // Get the name and the type of a field that will be // serialized as an XML attribute. String xmlAttributeNamespace = "http://example.org/ExampleAttributeNamespace"; String xmlAttributeName = "ExampleFieldAttributeName"; SoapServices.GetInteropFieldTypeAndNameFromXmlAttribute(containingType, xmlAttributeName, xmlAttributeNamespace, fieldType, fieldName); Console.WriteLine("The type of the field is {0}.", fieldType); Console.WriteLine("The name of the field is {0}.", fieldName); String interopTypeXmlElementName = "ExampleClassElementName"; String interopTypeXmlNamespace = "http://example.org/ExampleXmlNamespace"; Type interopType = SoapServices.GetInteropTypeFromXmlElement( interopTypeXmlElementName, interopTypeXmlNamespace); Console.WriteLine("The interop type is {0}.", interopType); String interopTypeXmlTypeName = "ExampleXmlTypeName"; String interopTypeXmlTypeNamespace = "http://example.org/ExampleXmlTypeNamespace"; interopType = SoapServices.GetInteropTypeFromXmlType( interopTypeXmlTypeName, interopTypeXmlTypeNamespace); Console.WriteLine("The interop type is {0}.", interopType); // Get the method base object for the GetHello method. System.Reflection.MethodBase methodBase = ExampleNamespace. ExampleClass.class.ToType().GetMethod("GetHello"); // Print its current SOAP action. Console.WriteLine("The SOAP action for the method " + "ExampleClass.GetHello is {0}.", SoapServices. GetSoapActionFromMethodBase(methodBase)); // Set the SOAP action of the GetHello method to a new value. String newSoapAction = "http://example.org/ExampleSoapAction#NewSoapAction"; SoapServices.RegisterSoapActionForMethodBase(methodBase, newSoapAction); Console.WriteLine("The SOAP action for the method " + "ExampleClass.GetHello is {0}.", SoapServices. GetSoapActionFromMethodBase(methodBase)); // Reset the SOAP action of the GetHello method to its default // value, which is determined using its SoapMethod attribute. SoapServices.RegisterSoapActionForMethodBase(methodBase); Console.WriteLine("The SOAP action for the method " + "ExampleClass.GetHello is {0}.", SoapServices. GetSoapActionFromMethodBase(methodBase)); // Register all types in the assembly with the SoapType attribute. System.Reflection.Assembly executingAssembly = System.Reflection. Assembly.GetExecutingAssembly(); SoapServices.PreLoad(executingAssembly); // Register a specific type with the SoapType attribute. Type exampleType = ExampleNamespace.ExampleClass.class.ToType(); SoapServices.PreLoad(exampleType); // Get the currently registered type for the given XML element // and namespace. String registeredXmlElementName = "ExampleClassElementName"; String registeredXmlNamespace = "http://example.org/ExampleXmlNamespace"; Type registeredType = SoapServices. GetInteropTypeFromXmlElement(registeredXmlElementName, registeredXmlNamespace); Console.WriteLine("The registered interop type is {0}.", registeredType); // Register a new type for the XML element and namespace. SoapServices.RegisterInteropXmlElement(registeredXmlElementName, registeredXmlNamespace, String.class.ToType()); // Get the currently registered type for the given XML element // and namespace. registeredType = SoapServices.GetInteropTypeFromXmlElement( registeredXmlElementName, registeredXmlNamespace); Console.WriteLine("The registered interop type is {0}.", registeredType); // Get the currently registered type for the given XML element // and namespace. String registeredXmlTypeName = "ExampleXmlTypeName"; String registeredXmlTypeNamespace = "http://example.org/ExampleXmlTypeNamespace"; registeredType = SoapServices.GetInteropTypeFromXmlType( registeredXmlTypeName, registeredXmlTypeNamespace); Console.WriteLine("The registered interop type is {0}.", registeredType); // Register a new type for the XML element and namespace. SoapServices.RegisterInteropXmlType(registeredXmlTypeName, registeredXmlTypeNamespace, String.class.ToType()); // Get the currently registered type for the given XML element // and namespace. registeredType = SoapServices.GetInteropTypeFromXmlType( registeredXmlTypeName, registeredXmlTypeNamespace); Console.WriteLine("The registered interop type is {0}.", registeredType); } //main } //Demo

- SecurityPermission (インフラストラクチャ コードを操作するために必要なアクセス許可)。要求値 : SecurityAction.LinkDemand; アクセス許可値 : SecurityPermissionFlag.Infrastructure

System.Runtime.Remoting.SoapServices


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SoapServices プロパティ

名前 | 説明 | |
---|---|---|
![]() | XmlNsForClrType | 共通言語ランタイム型の XML 名前空間プレフィックスを取得します。 |
![]() | XmlNsForClrTypeWithAssembly | アセンブリを持ち、ネイティブ名前空間のない共通言語ランタイム クラスの XML エンコーディングに使用する、既定の XML 名前空間プレフィックスを取得します。 |
![]() | XmlNsForClrTypeWithNs | mscorlib.dll ファイルの一部である共通言語ランタイム クラスの XML エンコーディングに使用する XML 名前空間プレフィックスを取得します。 |
![]() | XmlNsForClrTypeWithNsAndAssembly | 共通言語ランタイム名前空間とアセンブリの両方を持つ共通言語ランタイム クラスの XML エンコーディングに使用する、既定の XML 名前空間プレフィックスを取得します。 |

SoapServices メソッド

名前 | 説明 | |
---|---|---|
![]() | CodeXmlNamespaceForClrTypeNamespace | 提供された名前空間とアセンブリの名前から共通言語ランタイム型名前空間の名前を返します。 |
![]() | DecodeXmlNamespaceForClrTypeNamespace | 指定された共通言語ランタイム名前空間から、XML 名前空間とアセンブリの名前をデコードします。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetInteropFieldTypeAndNameFromXmlAttribute | XML 属性名、名前空間、および格納オブジェクトの Type からフィールドの種類を取得します。 |
![]() | GetInteropFieldTypeAndNameFromXmlElement | 提供された XML 要素名、名前空間、および格納オブジェクトの型からフィールドの Type と名前を取得します。 |
![]() | GetInteropTypeFromXmlElement | 特定の XML 要素名と名前空間で、認識されないオブジェクト型の逆シリアル化中に使用する Type を取得します。 |
![]() | GetInteropTypeFromXmlType | 特定の XML 型名と名前空間で認識されないオブジェクト型の逆シリアル化中に使用するオブジェクト Type を取得します。 |
![]() | GetSoapActionFromMethodBase | 特定の MethodBase で指定したメソッドと関連付けられた SOAPAction 値を返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | GetTypeAndMethodNameFromSoapAction | 指定した SOAPAction 値と関連付けられたメソッドの型とメソッド名を確認します。 |
![]() | GetXmlElementForInteropType | 特定の型をシリアル化するときに使用する XML 要素情報を返します。 |
![]() | GetXmlNamespaceForMethodCall | 特定の MethodBase で指定したメソッドのリモート呼び出し中に使用する XML 名前空間を取得します。 |
![]() | GetXmlNamespaceForMethodResponse | 特定の MethodBase で指定したメソッドのリモート呼び出しへの応答生成中に使用する XML 名前空間を取得します。 |
![]() | GetXmlTypeForInteropType | 特定の Type をシリアル化するときに使用する XML 型情報を返します。 |
![]() | IsClrTypeNamespace | 指定した名前空間が共通言語ランタイムに対してネイティブかどうかを示すブール値を返します。 |
![]() | IsSoapActionValidForMethodBase | 指定した SOAPAction が特定の MethodBase で許容されるかどうかを確認します。 |
![]() | PreLoad | オーバーロードされます。 型に適用される SoapTypeAttribute で設定した値に基づいて、指定した型をプリロードします。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | RegisterInteropXmlElement | 特定の XML 要素名と名前空間を、逆シリアル化に使用するランタイム型と関連付けます。 |
![]() | RegisterInteropXmlType | 特定の XML 型名と名前空間を、逆シリアル化に使用するランタイム型と関連付けます。 |
![]() | RegisterSoapActionForMethodBase | オーバーロードされます。 提供された MethodBase と SOAPAction 値を関連付けます。 |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

SoapServices メンバ
SOAP 形式でリモート オブジェクトを使用および公開するための複数のメソッドを提供します。
SoapServices データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | XmlNsForClrType | 共通言語ランタイム型の XML 名前空間プレフィックスを取得します。 |
![]() | XmlNsForClrTypeWithAssembly | アセンブリを持ち、ネイティブ名前空間のない共通言語ランタイム クラスの XML エンコーディングに使用する、既定の XML 名前空間プレフィックスを取得します。 |
![]() | XmlNsForClrTypeWithNs | mscorlib.dll ファイルの一部である共通言語ランタイム クラスの XML エンコーディングに使用する XML 名前空間プレフィックスを取得します。 |
![]() | XmlNsForClrTypeWithNsAndAssembly | 共通言語ランタイム名前空間とアセンブリの両方を持つ共通言語ランタイム クラスの XML エンコーディングに使用する、既定の XML 名前空間プレフィックスを取得します。 |

名前 | 説明 | |
---|---|---|
![]() | CodeXmlNamespaceForClrTypeNamespace | 提供された名前空間とアセンブリの名前から共通言語ランタイム型名前空間の名前を返します。 |
![]() | DecodeXmlNamespaceForClrTypeNamespace | 指定された共通言語ランタイム名前空間から、XML 名前空間とアセンブリの名前をデコードします。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetInteropFieldTypeAndNameFromXmlAttribute | XML 属性名、名前空間、および格納オブジェクトの Type からフィールドの種類を取得します。 |
![]() | GetInteropFieldTypeAndNameFromXmlElement | 提供された XML 要素名、名前空間、および格納オブジェクトの型からフィールドの Type と名前を取得します。 |
![]() | GetInteropTypeFromXmlElement | 特定の XML 要素名と名前空間で、認識されないオブジェクト型の逆シリアル化中に使用する Type を取得します。 |
![]() | GetInteropTypeFromXmlType | 特定の XML 型名と名前空間で認識されないオブジェクト型の逆シリアル化中に使用するオブジェクト Type を取得します。 |
![]() | GetSoapActionFromMethodBase | 特定の MethodBase で指定したメソッドと関連付けられた SOAPAction 値を返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | GetTypeAndMethodNameFromSoapAction | 指定した SOAPAction 値と関連付けられたメソッドの型とメソッド名を確認します。 |
![]() | GetXmlElementForInteropType | 特定の型をシリアル化するときに使用する XML 要素情報を返します。 |
![]() | GetXmlNamespaceForMethodCall | 特定の MethodBase で指定したメソッドのリモート呼び出し中に使用する XML 名前空間を取得します。 |
![]() | GetXmlNamespaceForMethodResponse | 特定の MethodBase で指定したメソッドのリモート呼び出しへの応答生成中に使用する XML 名前空間を取得します。 |
![]() | GetXmlTypeForInteropType | 特定の Type をシリアル化するときに使用する XML 型情報を返します。 |
![]() | IsClrTypeNamespace | 指定した名前空間が共通言語ランタイムに対してネイティブかどうかを示すブール値を返します。 |
![]() | IsSoapActionValidForMethodBase | 指定した SOAPAction が特定の MethodBase で許容されるかどうかを確認します。 |
![]() | PreLoad | オーバーロードされます。 型に適用される SoapTypeAttribute で設定した値に基づいて、指定した型をプリロードします。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | RegisterInteropXmlElement | 特定の XML 要素名と名前空間を、逆シリアル化に使用するランタイム型と関連付けます。 |
![]() | RegisterInteropXmlType | 特定の XML 型名と名前空間を、逆シリアル化に使用するランタイム型と関連付けます。 |
![]() | RegisterSoapActionForMethodBase | オーバーロードされます。 提供された MethodBase と SOAPAction 値を関連付けます。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- SoapServicesのページへのリンク