Inquiridor
Web Service - XML - não consigo sair do lugar

Pergunta
-
Caros colegas, acho que meu problema é XML e não Web Service, mas vamos lá. Tenho que consumir um WS e não consigo gerar o pacote para enviá-lo:
Tem uma classe gerada pelo WSDL que é a seguinte:
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:tha.com.br:ps.maxor")> _
Partial Public Class OrcamentoProjeto
Private codigoProjetoField As String
Private estruturaField() As OrcamentoProjetoEstrutura
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property CodigoProjeto() As String
Get
Return Me.codigoProjetoField
End Get
Set
Me.codigoProjetoField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("Estrutura", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Estrutura() As OrcamentoProjetoEstrutura()
Get
Return Me.estruturaField
End Get
Set
Me.estruturaField = value
End Set
End Property
End Classe outra é essa:
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn:tha.com.br:ps.maxor")> _
Partial Public Class OrcamentoProjetoEstrutura
Private codigoField As String
Private nivelField As OrcamentoProjetoEstruturaNivel
Private codigoPaiField As String
Private servicoField() As OrcamentoProjetoEstruturaServico
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Codigo() As String
Get
Return Me.codigoField
End Get
Set
Me.codigoField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Nivel() As OrcamentoProjetoEstruturaNivel
Get
Return Me.nivelField
End Get
Set
Me.nivelField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property CodigoPai() As String
Get
Return Me.codigoPaiField
End Get
Set
Me.codigoPaiField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("Servico", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Servico() As OrcamentoProjetoEstruturaServico()
Get
Return Me.servicoField
End Get
Set
Me.servicoField = value
End Set
End Property
End ClassAí há uma função
Public Overloads Sub OrcamentoProjeto_Asy_OutAsync(ByVal OrcamentoProjeto As OrcamentoProjeto)
Me.OrcamentoProjeto_Asy_OutAsync(OrcamentoProjeto, Nothing)
End SubE NÃO consigo construir esse parâmetro "OrcamentoProjeto"
Alguém tem uma ideia?
Todas as Respostas
-
-
-
Caro Charles, obrigado por responder.
Veja meu código abaixo:
Dim Sele As String = "", I As Integer = 0
Sele = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & txtArqui.Text & ";Persist Security Info=False"
Dim Cnn As New OleDb.OleDbConnection(Sele)
Cnn.Open()
Dim cm As New OleDb.OleDbCommand("SELECT MatTer as CodigoProjeto FROM Dados", Cnn)
Dim dr As OleDb.OleDbDataReader = cm.ExecuteReaderDim p As New OrcamentoProjeto 'somente uma linha
If dr.HasRows Then
dr.Read()
p.CodigoProjeto = dr("CodigoProjeto")
End If
dr.Close()Dim ope As New OrcamentoProjetoEstrutura()
Dim qni As New OrcamentoProjetoEstruturaNivel()
cm.CommandText = "SELECT Modulo as Codigo, 1 as Nivel, '0' as CodigoPai FROM Modulos"
dr = cm.ExecuteReader
If dr.HasRows Then
Do While dr.Read()
ope.Codigo = dr!Codigo
qni = dr!nivel
ope.Nivel = qni
Loop
End If
dr.Close()'***********************é aqui que não consigo ir adiante ***********************
'Não consigo construir o objeto "OrcamentoProjeto"
'*********************** abaixo as classes utilizadas ***************************
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:tha.com.br:ps.maxor")> _
Partial Public Class OrcamentoProjeto
Private codigoProjetoField As String
Private estruturaField() As OrcamentoProjetoEstrutura
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property CodigoProjeto() As String
Get
Return Me.codigoProjetoField
End Get
Set
Me.codigoProjetoField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("Estrutura", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Estrutura() As OrcamentoProjetoEstrutura()
Get
Return Me.estruturaField
End Get
Set
Me.estruturaField = value
End Set
End Property
End Class'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn:tha.com.br:ps.maxor")> _
Partial Public Class OrcamentoProjetoEstrutura
Private codigoField As String
Private nivelField As OrcamentoProjetoEstruturaNivel
Private codigoPaiField As String
Private servicoField() As OrcamentoProjetoEstruturaServico
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Codigo() As String
Get
Return Me.codigoField
End Get
Set
Me.codigoField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Nivel() As OrcamentoProjetoEstruturaNivel
Get
Return Me.nivelField
End Get
Set
Me.nivelField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property CodigoPai() As String
Get
Return Me.codigoPaiField
End Get
Set
Me.codigoPaiField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("Servico", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Servico() As OrcamentoProjetoEstruturaServico()
Get
Return Me.servicoField
End Get
Set
Me.servicoField = value
End Set
End Property
End Class'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
System.SerializableAttribute(), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn:tha.com.br:ps.maxor")> _
Public Enum OrcamentoProjetoEstruturaNivel
'''<remarks/>
<System.Xml.Serialization.XmlEnumAttribute("1")> _
Item1
'''<remarks/>
<System.Xml.Serialization.XmlEnumAttribute("2")> _
Item2
'''<remarks/>
<System.Xml.Serialization.XmlEnumAttribute("3")> _
Item3
End Enum'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn:tha.com.br:ps.maxor")> _
Partial Public Class OrcamentoProjetoEstruturaServico
Private codigoAuxiliarField As String
Private descricaoField As String
Private controleField As Boolean
Private insumoField() As OrcamentoProjetoEstruturaServicoInsumo
Public Sub New()
MyBase.New
Me.controleField = false
End Sub
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property CodigoAuxiliar() As String
Get
Return Me.codigoAuxiliarField
End Get
Set
Me.codigoAuxiliarField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Descricao() As String
Get
Return Me.descricaoField
End Get
Set
Me.descricaoField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Controle() As Boolean
Get
Return Me.controleField
End Get
Set
Me.controleField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("Insumo", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Insumo() As OrcamentoProjetoEstruturaServicoInsumo()
Get
Return Me.insumoField
End Get
Set
Me.insumoField = value
End Set
End Property
End Class'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn:tha.com.br:ps.maxor")> _
Partial Public Class OrcamentoProjetoEstruturaServicoInsumo
Private codigoAuxiliarField As String
Private tipoField As OrcamentoProjetoEstruturaServicoInsumoTipo
Private quantidadeField As Decimal
Private unidadeMedidaField As String
Private precoUnitarioField As Decimal
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property CodigoAuxiliar() As String
Get
Return Me.codigoAuxiliarField
End Get
Set
Me.codigoAuxiliarField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Tipo() As OrcamentoProjetoEstruturaServicoInsumoTipo
Get
Return Me.tipoField
End Get
Set
Me.tipoField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Quantidade() As Decimal
Get
Return Me.quantidadeField
End Get
Set
Me.quantidadeField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property UnidadeMedida() As String
Get
Return Me.unidadeMedidaField
End Get
Set
Me.unidadeMedidaField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property PrecoUnitario() As Decimal
Get
Return Me.precoUnitarioField
End Get
Set
Me.precoUnitarioField = value
End Set
End Property
End Class'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
System.SerializableAttribute(), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn:tha.com.br:ps.maxor")> _
Public Enum OrcamentoProjetoEstruturaServicoInsumoTipo
'''<remarks/>
<System.Xml.Serialization.XmlEnumAttribute("1")> _
Item1
'''<remarks/>
<System.Xml.Serialization.XmlEnumAttribute("3")> _
Item3
End Enum -
você ja tentou usar o web service diretamente?
tipo esse q eu digito um CEP e pego o resultado dos correios
string xml = "http://webservice.com.br/web_cep.php?auth=9bfe855fc40ed1ab90a34820d6e7a4ac&formato=xml&cep=@cep".Replace("@cep", txtCEP.Text.Trim()); DataSet ds = new DataSet(); Session["validar"] = "N"; ds.ReadXml(xml); DataTable DT = new DataTable(); int result = 0; DT = ds.Tables[0]; // System.Threading.Thread.Sleep(3000); foreach (DataRow drw in DT.Rows) { txtBairro.Text = Convert.ToString(drw["bairro"]); txtCidade.Text = Convert.ToString(drw["cidade"]); txtUF.Text = Convert.ToString(drw["uf"]); txtEndere.Text = Convert.ToString(drw["logradouro"]); result = Convert.ToInt16((drw["resultado"])); } if (result == 0) { clMessageBox.Show("Endereço não encontrado"); }
Charles Tenorio
-