【问题标题】:vb.net use checkVatService.wsdlvb.net 使用 checkVatService.wsdl
【发布时间】:2017-11-10 10:42:11
【问题描述】:

http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl 检查意大利的增值税。 这是我写的

Public Function check_piva() As Date
    Dim pivawe As New checkvatService.europa.ec.checkVatService
    Dim piva As String = "0798012121lk9"
    Dim bb As Boolean
    Dim s As String
    Dim n As String = String.Empty
    Dim data As Date
    data = pivawe.checkVat("IT", piva, bb, n, n)
    MsgBox(data)
    Return data

如果增值税错误或正确,它总是返回今天的数据,我也不明白为什么 checkVAt 函数返回的日期不是字符串或布尔值

我看到他们也有checkVatAsync

Dim pivawe As New checkvatService.europa.ec.checkVatService
Dim piva As String = "0798012121lk9"
Dim bb As Boolean
Dim s As String
Dim n As String = String.Empty
Dim data As Date
pivawe.checkVatAsync("IT", piva)
MsgBox(data)
Return data     

这运行没有错误,但我没有返回值。如果我写

s = pivawe.checkVatAsync("IT", piva)

我得到错误

表达式不产生值。

可能是 Web 服务根本不起作用。 任何建议thx

【问题讨论】:

    标签: vb.net


    【解决方案1】:

    我不太了解您要归档的内容,但假设您需要验证增值税号。然后你只需要消耗它。在下面的示例中,我在soap 请求中立即传递了国家和增值税号码,但您可以轻松地进行字符串连接并在那里传递动态变量。

    Imports System.Net
    
    Module Module1
    
        Sub Main()
    
            Dim client As WebClient = New WebClient()
            client.Encoding = System.Text.Encoding.UTF8
    
            Dim request As String = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:urn=""urn:ec.europa.eu:taxud:vies:services:checkVat:types"">
                <soapenv:Header/>
                <soapenv:Body>
                  <urn:checkVat>
                     <urn:countryCode>IT</urn:countryCode>
                     <urn:vatNumber>XXXXXXXXXXX</urn:vatNumber>
                  </urn:checkVat>
                </soapenv:Body>
                </soapenv:Envelope>"
    
            Dim response As String = ""
    
            Try
                response = client.UploadString("http://ec.europa.eu/taxation_customs/vies/services/checkVatService", request)
            Catch
                Console.WriteLine("Exception")
                'service throws WebException e.g. when non-EU VAT Is supplied
            End Try
    
            Console.WriteLine(response)
            Console.WriteLine("")
    
            If response.Contains("<valid>true</valid>") Then
                Console.WriteLine("VALID")
            Else
                Console.WriteLine("NOT")
            End If
    
            Console.ReadLine()
    
        End Sub
    
    End Module
    

    这将使用 SOAP 并回复增值税在该国家/地区是否有效。 XXXXXXXXXXXX =增值税号;)您也可以将它们转换为变量,因为Borek的这个出色的答案here有!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-16
      • 1970-01-01
      • 2015-09-08
      • 1970-01-01
      • 2015-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多