// used by the client internal IMessage FormatResponse(ISoapMessage soapMsg, IMethodCallMessage mcm) { IMessage rtnMsg; if(soapMsg.MethodName == "Fault") { // an exception was thrown by the server Exception e = new SerializationException(); int i = Array.IndexOf(soapMsg.ParamNames, "detail"); if(_serverFaultExceptionField != null) // todo: revue this 'cause it's not safe e = (Exception) _serverFaultExceptionField.GetValue( soapMsg.ParamValues[i]); rtnMsg = new ReturnMessage((System.Exception)e, mcm); } else { object rtnObject = null; //RemMessageType messageType; // Get the output of the function if it is not *void* if(_methodCallInfo.ReturnType != typeof(void)){ int index = Array.IndexOf(soapMsg.ParamNames, "return"); rtnObject = soapMsg.ParamValues[index]; if(rtnObject is IConvertible) rtnObject = Convert.ChangeType( rtnObject, _methodCallInfo.ReturnType); } object[] outParams = new object [_methodCallParameters.Length]; int n=0; // check if there are *out* parameters foreach(ParameterInfo paramInfo in _methodCallParameters) { if(paramInfo.ParameterType.IsByRef || paramInfo.IsOut) { int index = Array.IndexOf(soapMsg.ParamNames, paramInfo.Name); object outParam = soapMsg.ParamValues[index]; if(outParam is IConvertible) outParam = Convert.ChangeType (outParam, paramInfo.ParameterType.GetElementType()); outParams[n] = outParam; } else outParams [n] = null; n++; } Header[] headers = new Header [2 + (soapMsg.Headers != null ? soapMsg.Headers.Length : 0)]; headers [0] = new Header ("__Return", rtnObject); headers [1] = new Header ("__OutArgs", outParams); if (soapMsg.Headers != null) soapMsg.Headers.CopyTo (headers, 2); rtnMsg = new MethodResponse (headers, mcm); } return rtnMsg; }
internal SoapWriter( Stream outStream, ISurrogateSelector selector, StreamingContext context, ISoapMessage soapMessage) { _xmlWriter = new XmlTextWriter(outStream, null); _xmlWriter.Formatting = Formatting.Indented; _surrogateSelector = selector; _context = context; _manager = new SerializationObjectManager(_context); }
public object Deserialize(Stream inStream, ISoapMessage soapMessage) { var savedCi = CultureInfo.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Deserialize_inner(inStream, soapMessage); } finally { Thread.CurrentThread.CurrentCulture = savedCi; } return(TopObject); }
private void SerializeMessage(ISoapMessage message) { bool firstTime; string ns = message.XmlNameSpace != null ? message.XmlNameSpace : defaultMessageNamespace; _xmlWriter.WriteStartElement("i2", message.MethodName, ns); Id(idGen.GetId(message, out firstTime)); string[] paramNames = message.ParamNames; object[] paramValues = message.ParamValues; int length = (paramNames != null)?paramNames.Length:0; for (int i = 0; i < length; i++) { _xmlWriter.WriteStartElement(paramNames[i]); SerializeComponent(paramValues[i], true); _xmlWriter.WriteEndElement(); } _xmlWriter.WriteFullEndElement(); }
private bool DeserializeMessage(ISoapMessage message) { string typeNamespace, assemblyName; if (xmlReader.Name == SoapTypeMapper.SoapEnvelopePrefix + ":Fault") { Deserialize(); return(false); } #if FIXED SoapServices.DecodeXmlNamespaceForClrTypeNamespace( xmlReader.NamespaceURI, out typeNamespace, out assemblyName); #endif message.MethodName = xmlReader.LocalName; message.XmlNameSpace = xmlReader.NamespaceURI; ArrayList paramNames = new ArrayList(); ArrayList paramValues = new ArrayList(); long paramValuesId = NextAvailableId; int[] indices = new int[1]; if (!xmlReader.IsEmptyElement) { int initialDepth = xmlReader.Depth; xmlReader.Read(); int i = 0; while (xmlReader.Depth > initialDepth) { long paramId, paramHref; object objParam = null; paramNames.Add(xmlReader.Name); Type paramType = null; if (message.ParamTypes != null) { if (i >= message.ParamTypes.Length) { throw new SerializationException("Not enough parameter types in SoapMessages"); } paramType = message.ParamTypes [i]; } indices[0] = i; objParam = DeserializeComponent( paramType, out paramId, out paramHref, paramValuesId, null, indices); indices[0] = paramValues.Add(objParam); if (paramHref != 0) { RecordFixup(paramValuesId, paramHref, paramValues.ToArray(), null, null, null, indices); } else if (paramId != 0) { // RegisterObject(paramId, objParam, null, paramValuesId, null, indices); } else { } i++; } xmlReader.ReadEndElement(); } else { xmlReader.Read(); } message.ParamNames = (string[])paramNames.ToArray(typeof(string)); message.ParamValues = paramValues.ToArray(); RegisterObject(paramValuesId, message.ParamValues, null, 0, null, null); return(true); }
void Deserialize_inner(Stream inStream, ISoapMessage soapMessage) { ArrayList headers = null; xmlReader = new XmlTextReader(inStream); xmlReader.WhitespaceHandling = WhitespaceHandling.None; mapper = new SoapTypeMapper(_binder); try { // SOAP-ENV:Envelope xmlReader.MoveToContent(); xmlReader.ReadStartElement(); xmlReader.MoveToContent(); // Read headers while (!(xmlReader.NodeType == XmlNodeType.Element && xmlReader.LocalName == "Body" && xmlReader.NamespaceURI == SoapTypeMapper.SoapEnvelopeNamespace)) { if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.LocalName == "Header" && xmlReader.NamespaceURI == SoapTypeMapper.SoapEnvelopeNamespace) { if (headers == null) { headers = new ArrayList(); } DeserializeHeaders(headers); } else { xmlReader.Skip(); } xmlReader.MoveToContent(); } // SOAP-ENV:Body xmlReader.ReadStartElement(); xmlReader.MoveToContent(); // The root object if (soapMessage != null) { if (DeserializeMessage(soapMessage)) { _topObjectId = NextAvailableId; RegisterObject(_topObjectId, soapMessage, null, 0, null, null); } xmlReader.MoveToContent(); if (headers != null) { soapMessage.Headers = (Header[])headers.ToArray(typeof(Header)); } } while (xmlReader.NodeType != XmlNodeType.EndElement) { Deserialize(); } // SOAP-ENV:Body xmlReader.ReadEndElement(); xmlReader.MoveToContent(); // SOAP-ENV:Envelope xmlReader.ReadEndElement(); } finally { if (xmlReader != null) { xmlReader.Close(); } } }
// used by the client internal IMessage FormatResponse(ISoapMessage soapMsg, IMethodCallMessage mcm) { IMessage rtnMsg; if (soapMsg.MethodName == "Fault") { // an exception was thrown by the server Exception e = new SerializationException(); int i = Array.IndexOf(soapMsg.ParamNames, "detail"); if (_serverFaultExceptionField != null) { // todo: revue this 'cause it's not safe e = (Exception)_serverFaultExceptionField.GetValue( soapMsg.ParamValues[i]); } rtnMsg = new ReturnMessage((System.Exception)e, mcm); } else { object rtnObject = null; //RemMessageType messageType; // Get the output of the function if it is not *void* if (_methodCallInfo.ReturnType != typeof(void)) { int index = Array.IndexOf(soapMsg.ParamNames, "return"); rtnObject = soapMsg.ParamValues[index]; if (rtnObject is IConvertible) { rtnObject = Convert.ChangeType( rtnObject, _methodCallInfo.ReturnType); } } object[] outParams = new object [_methodCallParameters.Length]; int n = 0; // check if there are *out* parameters foreach (ParameterInfo paramInfo in _methodCallParameters) { if (paramInfo.ParameterType.IsByRef || paramInfo.IsOut) { int index = Array.IndexOf(soapMsg.ParamNames, paramInfo.Name); object outParam = soapMsg.ParamValues[index]; if (outParam is IConvertible) { outParam = Convert.ChangeType(outParam, paramInfo.ParameterType.GetElementType()); } outParams[n] = outParam; } else { outParams [n] = null; } n++; } Header[] headers = new Header [2 + (soapMsg.Headers != null ? soapMsg.Headers.Length : 0)]; headers [0] = new Header("__Return", rtnObject); headers [1] = new Header("__OutArgs", outParams); if (soapMsg.Headers != null) { soapMsg.Headers.CopyTo(headers, 2); } rtnMsg = new MethodResponse(headers, mcm); } return(rtnMsg); }
void Serialize_inner(object objGraph, Header[] headers, FormatterTypeStyle typeFormat, FormatterAssemblyStyle assemblyFormat) { _typeFormat = typeFormat; _assemblyFormat = assemblyFormat; // Create the XmlDocument with the // Envelope and Body elements _mapper = new SoapTypeMapper(_xmlWriter, assemblyFormat, typeFormat); // The root element _xmlWriter.WriteStartElement( SoapTypeMapper.SoapEnvelopePrefix, "Envelope", SoapTypeMapper.SoapEnvelopeNamespace); // adding namespaces _xmlWriter.WriteAttributeString( "xmlns", "xsi", "http://www.w3.org/2000/xmlns/", "http://www.w3.org/2001/XMLSchema-instance"); _xmlWriter.WriteAttributeString( "xmlns", "xsd", "http://www.w3.org/2000/xmlns/", XmlSchema.Namespace); _xmlWriter.WriteAttributeString( "xmlns", SoapTypeMapper.SoapEncodingPrefix, "http://www.w3.org/2000/xmlns/", SoapTypeMapper.SoapEncodingNamespace); _xmlWriter.WriteAttributeString( "xmlns", SoapTypeMapper.SoapEnvelopePrefix, "http://www.w3.org/2000/xmlns/", SoapTypeMapper.SoapEnvelopeNamespace); _xmlWriter.WriteAttributeString( "xmlns", "clr", "http://www.w3.org/2000/xmlns/", SoapServices.XmlNsForClrType); _xmlWriter.WriteAttributeString( SoapTypeMapper.SoapEnvelopePrefix, "encodingStyle", SoapTypeMapper.SoapEnvelopeNamespace, "http://schemas.xmlsoap.org/soap/encoding/"); ISoapMessage msg = objGraph as ISoapMessage; if (msg != null) { headers = msg.Headers; } if (headers != null && headers.Length > 0) { _xmlWriter.WriteStartElement(SoapTypeMapper.SoapEnvelopePrefix, "Header", SoapTypeMapper.SoapEnvelopeNamespace); foreach (Header h in headers) { SerializeHeader(h); } WriteObjectQueue(); _xmlWriter.WriteEndElement(); } // The body element _xmlWriter.WriteStartElement( SoapTypeMapper.SoapEnvelopePrefix, "Body", SoapTypeMapper.SoapEnvelopeNamespace); bool firstTime = false; if (msg != null) { SerializeMessage(msg); } else { _objectQueue.Enqueue(new EnqueuedObject(objGraph, idGen.GetId(objGraph, out firstTime))); } WriteObjectQueue(); _xmlWriter.WriteFullEndElement(); // the body element _xmlWriter.WriteFullEndElement(); // the envelope element _xmlWriter.Flush(); }
protected void Page_Load(object sender, EventArgs e) { var fileControl = new FileControl(Int32.Parse("MaxFileSize".GetFromAppCfg())); // fileControl._CreateFolderInFTP(@"CC1077845378\Diego", "OPERADOR_REPOSITORY_USER"); string r = "<Asunto>Pruebas</Asunto><Mensaje>Pruebas</Mensaje><NombreEnvia>Centralizador</NombreEnvia><Origen><NumeroIdentificacion>1077845378</NumeroIdentificacion><tipoIdentificacion>1</tipoIdentificacion></Origen><archivos><ArchivoExpedidoPor>diego</ArchivoExpedidoPor><Contenido>asdfasfadsf</Contenido><FechaCargueArchivo>2014-10-24T00:00:00</FechaCargueArchivo><FechaExpedicionArchivo>2014-10-24T00:00:00</FechaExpedicionArchivo><FechaVigencia>2014-10-24T00:00:00</FechaVigencia><NombreArchivo>diego.png</NombreArchivo></archivos><archivos><ArchivoExpedidoPor>diego</ArchivoExpedidoPor><Contenido>asdfasfadsf</Contenido><FechaCargueArchivo>2014-10-24T00:00:00</FechaCargueArchivo><FechaExpedicionArchivo>2014-10-24T00:00:00</FechaExpedicionArchivo><FechaVigencia>2014-10-24T00:00:00</FechaVigencia><NombreArchivo>diego.png</NombreArchivo></archivos><destinatarios><NumeroIdentificacion>10777845378</NumeroIdentificacion><tipoIdentificacion>1</tipoIdentificacion></destinatarios>"; XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(r); XmlNodeList destinos = xDoc.GetElementsByTagName("Destinatarios"); XmlNodeList archivo = xDoc.GetElementsByTagName("archivo"); XmlNodeList xnList = xDoc.SelectNodes("archivo"); ISoapMessage a = new ISoapMessage(); crearSOAP(new Operador.Entity.TransferenciaMensajes()); a.Uri = "http://localhost/servicios/servicioweb/Service1.asmx"; a.ContentXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns=""http://tempuri.org/""> <soapenv:Header/> <soapenv:Body> <ValidarExistenciaUsuario> <!--Optional:--> <usuario> <!--Optional:--> <UUID>mmmm</UUID> <idTipoIdentificacion>1</idTipoIdentificacion> <!--Optional:--> <numeroIdentificacion>1077845378</numeroIdentificacion> <idMunicipioExpedicionDocumento>1</idMunicipioExpedicionDocumento> <fechaExpedicion>2015-06-30</fechaExpedicion> <!--Optional:--> <primerApellido>?</primerApellido> <!--Optional:--> <segundoApellido>?</segundoApellido> <!--Optional:--> <primerNombre>?</primerNombre> <!--Optional:--> <segundoNombre>?</segundoNombre> <!--Optional:--> <genero>m</genero> <fechaNacimiento>2015-06-30</fechaNacimiento> <idMunicipioNacimiento>1</idMunicipioNacimiento> <idPaisNacionalidad>233</idPaisNacionalidad> <idMunicipioResidencia>1</idMunicipioResidencia> <!--Optional:--> <direccionResidencia>8</direccionResidencia> <idMunicipioNotificacionCorrespondencia>1</idMunicipioNotificacionCorrespondencia> <!--Optional:--> <direccionNotificacionCorrespondencia>8</direccionNotificacionCorrespondencia> <!--Optional:--> <telefono>8</telefono> <!--Optional:--> <correoElectronico>8</correoElectronico> <idMunicipioLaboral>1</idMunicipioLaboral> <!--Optional:--> <estadoCivil>a</estadoCivil> <idOperador>1</idOperador> </usuario> </ValidarExistenciaUsuario> </soapenv:Body> </soapenv:Envelope>"; a.SoapAction = "http://tempuri.org/ValidarExistenciaUsuario"; Operador.Entity.UsuarioOperador nuevo = new Operador.Entity.UsuarioOperador(); Centralizador.Usuario nuevos = new Centralizador.Usuario(); var x = Uniandes.Utilidades.ExtensionMethods.ToXML(nuevo); var y = Uniandes.Utilidades.ExtensionMethods.ToXML(nuevos); var ALGO = CallWebService(a.ContentXml); }
internal SoapWriter( Stream outStream, ISurrogateSelector selector, StreamingContext context, ISoapMessage soapMessage) { _xmlWriter = new XmlTextWriter(outStream, null); _xmlWriter.Formatting = Formatting.Indented; _surrogateSelector = selector; _context = context; #if NET_2_0 && !TARGET_JVM _manager = new SerializationObjectManager (_context); #endif }
private void SerializeMessage(ISoapMessage message) { bool firstTime; string ns = message.XmlNameSpace != null ? message.XmlNameSpace : defaultMessageNamespace; _xmlWriter.WriteStartElement("i2", message.MethodName, ns); Id(idGen.GetId(message, out firstTime)); string[] paramNames = message.ParamNames; object[] paramValues = message.ParamValues; int length = (paramNames != null)?paramNames.Length:0; for(int i = 0; i < length; i++) { _xmlWriter.WriteStartElement(paramNames[i]); SerializeComponent(paramValues[i], true); _xmlWriter.WriteEndElement(); } _xmlWriter.WriteFullEndElement(); }
protected void Page_Load(object sender, EventArgs e) { var fileControl = new FileControl(Int32.Parse("MaxFileSize".GetFromAppCfg())); // fileControl._CreateFolderInFTP(@"CC1077845378\Diego", "OPERADOR_REPOSITORY_USER"); ISoapMessage a = new ISoapMessage(); a.Uri = "http://localhost/servicios/servicioweb/Service1.asmx"; a.ContentXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns=""http://tempuri.org/""> <soapenv:Header/> <soapenv:Body> <ValidarExistenciaUsuario> <!--Optional:--> <usuario> <!--Optional:--> <UUID>mmmm</UUID> <idTipoIdentificacion>1</idTipoIdentificacion> <!--Optional:--> <numeroIdentificacion>1077845378</numeroIdentificacion> <idMunicipioExpedicionDocumento>1</idMunicipioExpedicionDocumento> <fechaExpedicion>2015-06-30</fechaExpedicion> <!--Optional:--> <primerApellido>?</primerApellido> <!--Optional:--> <segundoApellido>?</segundoApellido> <!--Optional:--> <primerNombre>?</primerNombre> <!--Optional:--> <segundoNombre>?</segundoNombre> <!--Optional:--> <genero>m</genero> <fechaNacimiento>2015-06-30</fechaNacimiento> <idMunicipioNacimiento>1</idMunicipioNacimiento> <idPaisNacionalidad>233</idPaisNacionalidad> <idMunicipioResidencia>1</idMunicipioResidencia> <!--Optional:--> <direccionResidencia>8</direccionResidencia> <idMunicipioNotificacionCorrespondencia>1</idMunicipioNotificacionCorrespondencia> <!--Optional:--> <direccionNotificacionCorrespondencia>8</direccionNotificacionCorrespondencia> <!--Optional:--> <telefono>8</telefono> <!--Optional:--> <correoElectronico>8</correoElectronico> <idMunicipioLaboral>1</idMunicipioLaboral> <!--Optional:--> <estadoCivil>a</estadoCivil> <idOperador>1</idOperador> </usuario> </ValidarExistenciaUsuario> </soapenv:Body> </soapenv:Envelope>"; a.SoapAction = "http://tempuri.org/ValidarExistenciaUsuario"; Operador.Entity.UsuarioOperador nuevo = new Operador.Entity.UsuarioOperador(); Centralizador.Entity.Usuario nuevos = new Centralizador.Entity.Usuario(); var x = Uniandes.Utilidades.ExtensionMethods.ToXML(nuevo); var y = Uniandes.Utilidades.ExtensionMethods.ToXML(nuevos); var ALGO = CallWebService(a.ContentXml); }
public WebRequest CreateRequest(ISoapMessage soapMessage) { var wr = WebRequest.Create(soapMessage.Uri); wr.ContentType = "text/xml;charset=utf-8"; wr.ContentLength = soapMessage.ContentXml.Length; wr.Headers.Add("SOAPAction", soapMessage.SoapAction); // wr.Credentials = soapMessage.Credentials; wr.Method = "POST"; wr.GetRequestStream().Write(Encoding.UTF8.GetBytes(soapMessage.ContentXml), 0, soapMessage.ContentXml.Length); return wr; }
private bool DeserializeMessage(ISoapMessage message) { string typeNamespace, assemblyName; if(xmlReader.Name == SoapTypeMapper.SoapEnvelopePrefix + ":Fault") { Deserialize(); return false; } SoapServices.DecodeXmlNamespaceForClrTypeNamespace( xmlReader.NamespaceURI, out typeNamespace, out assemblyName); message.MethodName = xmlReader.LocalName; message.XmlNameSpace = xmlReader.NamespaceURI; ArrayList paramNames = new ArrayList(); ArrayList paramValues = new ArrayList(); long paramValuesId = NextAvailableId; int[] indices = new int[1]; if (!xmlReader.IsEmptyElement) { int initialDepth = xmlReader.Depth; xmlReader.Read(); int i = 0; while(xmlReader.Depth > initialDepth) { long paramId, paramHref; object objParam = null; paramNames.Add (xmlReader.Name); Type paramType = null; if (message.ParamTypes != null) { if (i >= message.ParamTypes.Length) throw new SerializationException ("Not enough parameter types in SoapMessages"); paramType = message.ParamTypes [i]; } indices[0] = i; objParam = DeserializeComponent( paramType, out paramId, out paramHref, paramValuesId, null, indices); indices[0] = paramValues.Add(objParam); if(paramHref != 0) { RecordFixup(paramValuesId, paramHref, paramValues.ToArray(), null, null, null, indices); } else if(paramId != 0) { // RegisterObject(paramId, objParam, null, paramValuesId, null, indices); } else { } i++; } xmlReader.ReadEndElement(); } else { xmlReader.Read(); } message.ParamNames = (string[]) paramNames.ToArray(typeof(string)); message.ParamValues = paramValues.ToArray(); RegisterObject(paramValuesId, message.ParamValues, null, 0, null, null); return true; }
public object Deserialize(Stream inStream, ISoapMessage soapMessage) { var savedCi = CultureInfo.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Deserialize_inner(inStream, soapMessage); } finally { Thread.CurrentThread.CurrentCulture = savedCi; } return TopObject; }
public object Deserialize(Stream inStream, ISoapMessage soapMessage) { ArrayList headers = null; xmlReader = new XmlTextReader(inStream); xmlReader.WhitespaceHandling = WhitespaceHandling.None; mapper = new SoapTypeMapper(_binder); try { // SOAP-ENV:Envelope xmlReader.MoveToContent(); xmlReader.ReadStartElement (); xmlReader.MoveToContent(); // Read headers while (!(xmlReader.NodeType == XmlNodeType.Element && xmlReader.LocalName == "Body" && xmlReader.NamespaceURI == SoapTypeMapper.SoapEnvelopeNamespace)) { if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.LocalName == "Header" && xmlReader.NamespaceURI == SoapTypeMapper.SoapEnvelopeNamespace) { if (headers == null) headers = new ArrayList (); DeserializeHeaders (headers); } else xmlReader.Skip (); xmlReader.MoveToContent(); } // SOAP-ENV:Body xmlReader.ReadStartElement(); xmlReader.MoveToContent(); // The root object if (soapMessage != null) { if (DeserializeMessage (soapMessage)) { _topObjectId = NextAvailableId; RegisterObject (_topObjectId, soapMessage, null, 0, null, null); } xmlReader.MoveToContent(); if (headers != null) soapMessage.Headers = (Header[]) headers.ToArray (typeof(Header)); } while (xmlReader.NodeType != XmlNodeType.EndElement) Deserialize(); // SOAP-ENV:Body xmlReader.ReadEndElement (); xmlReader.MoveToContent(); // SOAP-ENV:Envelope xmlReader.ReadEndElement (); } finally { if(xmlReader != null) xmlReader.Close(); } return TopObject; }
internal SoapWriter( Stream outStream, ISurrogateSelector selector, StreamingContext context, ISoapMessage soapMessage) { _xmlWriter = new XmlTextWriter(outStream, null); _xmlWriter.Formatting = Formatting.Indented; _surrogateSelector = selector; _context = context; }