Passing custom object as parameter to asp.net web service web method
I have a custom class declared as follows (in vb.net)
<Serializable()>
Public Class NumInfo
Public n As String
Public f As Integer
Public fc As char()
Public t As Integer
Public tc As char()
Private validFlag As Boolean = True
Public Sub New()
End Sub
'I also have public properties(read/write) for all the public variables
End Class
In my service.asmx codebehind class, I have a web method like this:
Public Function ConvertTo(ByVal info As NumInfo) As String
Return mbc(info)<br>'mbc is another function defined in my service.asmx "service" class
End Function
The problem is that when I start debugging it to test it, the page I get does not contain fields where I could enter values for the public numInfo fields. How do I initialize a class? There is no Call button. All I can see is soap data as shown below:
ConvertTo
Test
Only test form is available for methods with primitive types as parameters.
SOAP 1.1
Below is an example SOAP 1.1 request and response. The placeholders shown should be replaced with actual values.
POST /Converter/BC.asmx
HTTP / 1.1
Host: localhost
Content-Type: text / xml; encoding = UTF-8
Content-Length: SOAPAction length
: " http: // Services / ConvertTo "
<? xml version = "1.0" encoding = "UTF-8">?
<soap: XMLNS envelope: XSI = "http://www.w3.org/2001/XMLSchema-instance"
XMLNS: XSD = "http://www.w3.org/2001/XMLSchema"
XMLNS: soap = "http://schemas.xmlsoap.org/soap/envelope/">
<soap: Body>
<ConvertTo xmlns = "http: // Services /">
<& GT Info;
& L; n> string </ n>
<& f gt; Int & l / f>
<& fc gt ;
<char> char </char>
<char> char> / char>
</ k>
..etc ..
What am I doing wrong? For the record, I tried replacing char () with a string to see if it was an array causing problems, but that didn't help . I am new to web services. I tried to replace the custom object parameter with a primitive parameter to test how things worked and rendered a page with an input field and a call button. I just can't get it to work with a custom object. Help!
a source to share