Need help in finding error in SOAP web service call

L

Lloyd Sheen

I generated the stubs for a web service that provides lyric information for
songs.

The URL of the wsdl is:

http://lyricwiki.org/server.php?wsdl

Some of the calls work with no problem but there are several which I have a
problem with:

The one I will use to illustrate the problem is a getArtist call. The
generated stub has a signature of :

Public Function getArtist(ByRef artist As String) As String()
Member of SongLyrics.org.lyricwiki.LyricWiki

The code I am using to get the error is:

Try
result = songSearch.getArtist(artist)
Catch ex As Exception

End Try

The message in the exception is:

{"There is an error in XML document (1, 533)."}
System.InvalidOperationException: {"There is an error in XML document
(1, 533)."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: Nothing
InnerException: {"Cannot assign object of type System.String to an
object of type System.String[]."}
Message: "There is an error in XML document (1, 533)."
Source: "System.Xml"
StackTrace: " at
System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader,
String encodingStyle, XmlDeserializationEvents events) at
System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader,
String encodingStyle) at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters) at
SongLyrics.org.lyricwiki.LyricWiki.getArtist(String& artist) in C:\Visual
Studio Projects\Brand New Music Console\SongLyrics\Web
References\org.lyricwiki\Reference.vb:line 334 at
New_Music_Console.SongViewUC.GetSongLyricsToolStripMenuItem_Click(Object
sender, EventArgs e) in C:\Visual Studio Projects\Brand New Music
Console\New Music Console\UserControls\SongViewUC.vb:line 1809"
TargetSite: {System.Reflection.RuntimeMethodInfo}


I have also captured the call thru Fiddler (what a great tool except that
the XML view does not have a copy).

Sent information:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="urn:LyricWiki" xmlns:types="urn:LyricWiki/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><tns:getArtist><artist
xsi:type="xsd:string">Amanda
Somerville</artist></tns:getArtist></soap:Body></soap:Envelope>

Recieved information:

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:si="http://soapinterop.org/xsd"
xmlns:tns="urn:LyricWiki"><SOAP-ENV:Body><ns1:getArtistResponse
xmlns:ns1="urn:LyricWiki"><artist xsi:type="xsd:string">Amanda
Somerville</artist><albums xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="tns:AlbumData[0]"></albums></ns1:getArtistResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

I don't know much about SOAP and rely on the generated code but I hope
someone can lead me to a cause. Even if the information is sent incorrectly
or recieved incorrectly I could get a hold of the people who are responsible
for the API and let them know.

Thanks
Lloyd Sheen
 
T

Tom Dacon

Lloyd Sheen said:
Public Function getArtist(ByRef artist As String) As String()
Member of SongLyrics.org.lyricwiki.LyricWiki

The code I am using to get the error is:

Try
result = songSearch.getArtist(artist)
Catch ex As Exception

End Try

Lloyd, assuming that result is declared as

dim result as String

then your function definition looks to me like it should be

Public Function getArtist(ByRef artist As String) As String

The parentheses in your original says that getArtist returns an array of
String.

HTH,
Tom Dacon
Dacon Software Consulting
 
L

Lloyd Sheen

Tom Dacon said:
Lloyd, assuming that result is declared as

dim result as String

then your function definition looks to me like it should be

Public Function getArtist(ByRef artist As String) As String

The parentheses in your original says that getArtist returns an array of
String.

HTH,
Tom Dacon
Dacon Software Consulting

Tom ,

If I try to define result as String rather than String() I get a compile
error. I should have shown the generated code for the function which is:

'''<remarks/>
<System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:LyricWiki#getArtist",
RequestNamespace:="urn:LyricWiki", ResponseNamespace:="urn:LyricWiki")> _
Public Function getArtist(ByRef artist As String) As
<System.Xml.Serialization.SoapElementAttribute("albums")> String()
Dim results() As Object = Me.Invoke("getArtist", New Object()
{artist})
artist = CType(results(1),String)
Return CType(results(0),String())
End Function

Thanks
Lloyd Sheen
 
T

Tom Dacon

Tom ,

If I try to define result as String rather than String() I get a
compile error. I should have shown the generated code for the function
which is:

'''<remarks/>

<System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:LyricWiki#getArtist",
RequestNamespace:="urn:LyricWiki", ResponseNamespace:="urn:LyricWiki")> _
Public Function getArtist(ByRef artist As String) As
<System.Xml.Serialization.SoapElementAttribute("albums")> String()
Dim results() As Object = Me.Invoke("getArtist", New Object()
{artist})
artist = CType(results(1),String)
Return CType(results(0),String())
End Function

Thanks
Lloyd Sheen

Looks like instead of these lines:
artist = CType(results(1),String)
Return CType(results(0),String())

you just need

Return artist

to return a single string instead of the array.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top