开发者

Constructing Function in VB.net SOAP web service to receive an Array

I have a specific problem that I have not yet found an answer to. Basically I need to pass a list of numbers into a function do some math and return them. I can pass one number at a time without a problem, however when I want to pass in an array I start to have issues.

My VB.net code looks like this...

<WebMethod()> _
Public Function ArrayTest(test As Double) As Double()
    Return test
End Function

I'm testing against this using Python with SUDS as my SOAP client. Here is the XML

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  xmlns:ns0="http://tempuri.org/"
  xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <ns1:Body>
      <ns0:ArrayTest>
        <ns0:test>603</ns0:test>
        <ns0:test>603</ns0:test>
        <ns0:test>607</ns0:test>
        <ns0:test>609</ns0:test>
      </ns0:ArrayTest>
    </ns1:Body>
</SOAP-ENV:Envelope>

I set a break point in the code, and looked at开发者_运维百科 the input values on the test variable, and the Array size always stays at zero. I've tried ParamArray, List, and several other things but I'm having no luck. Of course if I don't specify the input to be an array, it takes the first item passed in from the SOAP request and returns it, but I'd like to get all items back.

Here is something else I tried to implement. I'm sure its something simple, I'm pretty new to programming in general. Related link


According to your code:

Public Function ArrayTest(test As Double) As Double()

ArrayTest recieves a Double, and return array of Double. May be you should just change your signature? Also, from link you've provided:

Public Function GetObjectValues(ByVal objIds As List(Of String), ByVal objProperty As String) As List(Of String)

Look at objIds parameter - List is an alternate variant for the Array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜