23/03/2006, 09:53
|
| | Fecha de Ingreso: mayo-2004 Ubicación: Guadalajara, Jalisco, México
Mensajes: 724
Antigüedad: 20 años, 8 meses Puntos: 6 | |
Hola rootK, sabes... vi tu respuesta y no mee parecio optima... Nosé.. invocar el metodo para ir agregan los parametros no se me hace una buena solucion...
Que haría yo en ese caso?
Bueno.. se me ocurre tener un xsd dentro de mi web service.. Y que el web service reciba un xml como peticion... como tu sabes.. el xml tiene el nombre de los campos (tags) y los valores (contenido de los tags) es decir...
<Usuario>
<ID>555</ID>
<Nombre>Maria</Nombre>
</Usuario>
Dentro de tu WS cargas tu xsd dentro de un xmldataDocument cargas el xml que recibe tu WS.. es decir.. la peticion...., tendrias que tener una funcion que te genere la lista de campos que estan en un xmldatadocument que estarán soportados en tu procedimiento almacenado...
algo asi...
Private Function getParameters(ByVal request As XmlElement) As NameValueCollection
Dim parameters As NameValueCollection
Dim xmlParameters As XmlNode = request
If Not xmlParameters Is Nothing Then
parameters = New NameValueCollection
For Each Node As XmlNode In xmlParameters
parameters.Add(Node.Name, Node.InnerText)
Next
End If
Return parameters
End Function
y cuando vayas a ejecutar tu SP recorrer lo que te regresa la funcion getParameters...
Public Function getResponse(ByVal spName As String, ByVal spParameters As NameValueCollection, ByVal nameService As String, ByVal nameTransacction As String) As DataSet
Dim sqlDa As SqlDataAdapter = New SqlDataAdapter(spName, AppSettings("Connection"))
'sqlDa.TableMappings.Add()
'sqlAdapter.TableMappings.Add("Table", ActivitiesData.TBL_ACTIVITIES)
With sqlDa.SelectCommand
.CommandType = CommandType.StoredProcedure
For i As Integer = 0 To spParameters.Count - 1
Dim sqlParam As New SqlParameter("@" & spParameters.GetKey(i), spParameters.GetValues(i)(0))
.Parameters.Add(sqlParam)
Next
End With
'Pasar el nombre del servicio
Dim ds As New DataSet
ds.ReadXmlSchema(HttpContext.Current.Request.Physi calApplicationPath & "/" & String.Format(AppSettings("responseFileXSD"), nameService, nameTransacction))
Dim index As Integer = 0
For Each tbl As DataTable In ds.Tables
sqlDa.TableMappings.Add("Table" & IIf(index = 0, "", index.ToString), tbl.TableName)
index += 1
Next
sqlDa.Fill(ds)
Return ds
End Function
Espero te sirva...
Saludos |