Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Services (http://www.velocityreviews.com/forums/f64-asp-net-web-services.html)
-   -   exception on Response Envelope, Error in XML-document (http://www.velocityreviews.com/forums/t787241-exception-on-response-envelope-error-in-xml-document.html)

msdnuniv 08-22-2007 01:30 PM

exception on Response Envelope, Error in XML-document
 
Hello!

i am desparetely trying to consume a PHP Webservice in VB.NET 2005.
I can add the webreference, compile without errors and see the methods of
the webservice.
But on runtime it tells me {"There is an error in XML document (6, 62)."}.
Inner Exception:
{"Cannot assign object of type System.Xml.XmlNode[] to an object of type
System.String."}

Envelope that comes from the webservice:
_________________________________________

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:ns1='urn:xmethods-mhd_ArticleDetails'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:ns2='http://xml.apache.org/xml-soap'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
<SOAP-ENV:Body>
<ns1:getArticleDetailsResponse>
<details xsi:type='ns2:Map'>
<item>
<key xsi:type='xsd:string'>
title
</key>
<value xsi:type='xsd:string'>
SGB 3 Sozialgesetzbuch Drittes Buch
</value>
</item>
<item>
<key xsi:type='xsd:string'>
headline
</key>
<value xsi:type='xsd:string'>
Viertes Kapitel: Leistungen an Arbeitnehmer Achter
Abschnitt: Entgeltersatzleistungen Zweiter Unterabschnitt: Arbeitslosengeld
Erster Titel: Regelvoraussetzungen
</value>
</item>
</details>
</ns1:getArticleDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Relevant part of WSDL (no complex types because i did not get them to import
at all in .NET):
__________________________
<message name="getArticleDetailsRequest">
<part name="artId" type="xsd:int"/>
</message>

<message name="getArticleDetailsResponse">
<part name="details" type="xsd:ArrayOfString"/>
</message>
____________

Strange: I defined ArrayOfString, but .NET expects just string.

How can I get that to run?
Thank you!

Best Regards,
Dirk



John Saunders [MVP] 08-22-2007 05:03 PM

Re: exception on Response Envelope, Error in XML-document
 
"msdnuniv" <dm4dm@newsgroup.nospam> wrote in message
news:O1zfjCM5HHA.5844@TK2MSFTNGP02.phx.gbl...
> Hello!
>
> i am desparetely trying to consume a PHP Webservice in VB.NET 2005.
> I can add the webreference, compile without errors and see the methods of
> the webservice.
> But on runtime it tells me {"There is an error in XML document (6, 62)."}.
> Inner Exception:
> {"Cannot assign object of type System.Xml.XmlNode[] to an object of type
> System.String."}
>
> Envelope that comes from the webservice:
> _________________________________________
>
> <?xml version='1.0' encoding='UTF-8'?>
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
> xmlns:ns1='urn:xmethods-mhd_ArticleDetails'
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
> xmlns:ns2='http://xml.apache.org/xml-soap'
> xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
> SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
> <SOAP-ENV:Body>
> <ns1:getArticleDetailsResponse>
> <details xsi:type='ns2:Map'>
> <item>
> <key xsi:type='xsd:string'>
> title
> </key>
> <value xsi:type='xsd:string'>
> SGB 3 Sozialgesetzbuch Drittes Buch
> </value>
> </item>
> <item>
> <key xsi:type='xsd:string'>
> headline
> </key>
> <value xsi:type='xsd:string'>
> Viertes Kapitel: Leistungen an Arbeitnehmer Achter
> Abschnitt: Entgeltersatzleistungen Zweiter Unterabschnitt:
> Arbeitslosengeld Erster Titel: Regelvoraussetzungen
> </value>
> </item>
> </details>
> </ns1:getArticleDetailsResponse>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
>
> Relevant part of WSDL (no complex types because i did not get them to
> import at all in .NET):
> __________________________
> <message name="getArticleDetailsRequest">
> <part name="artId" type="xsd:int"/>
> </message>
>
> <message name="getArticleDetailsResponse">
> <part name="details" type="xsd:ArrayOfString"/>
> </message>
> ____________
>
> Strange: I defined ArrayOfString, but .NET expects just string.


Please post the WSDL, so we can see _how_ you defined ArrayOfString.

Also, why did you define it in the "xsd" namespace? That's not your
namespace, so you don't get to change it.

Also, it doesn't look like the service is sending ArrayOfString, unless
ArrayOfString is the same thing as ns2:Map.
--
John Saunders [MVP]


Steven Cheng[MSFT] 08-23-2007 05:19 AM

Re: exception on Response Envelope, Error in XML-document
 
thanks for John's input.

Hi Dirk,

I agree with John that the problem is likely caused by the type mismatching
between the generated webservice client proxy and the corresponding object
member in the SOAP response message. As the following line indicates:

=========
{"Cannot assign object of type System.Xml.XmlNode[] to an object of type
System.String."}
=========

the webservice proxy class contains a string member while the SOAP response
message return an node list(array), at least the .net webservice
deserializer deserialize it into a nodelist which cause the type
mismatching problem.

Please feel free to post some further info(like WSDL document) so that we
can have a look and perform some test on it.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.




msdnuniv 08-23-2007 05:06 PM

Re: exception on Response Envelope, Error in XML-document
 
> Hello!
>>
>> i am desparetely trying to consume a PHP Webservice in VB.NET 2005.

....
>>
>> Relevant part of WSDL (no complex types because i did not get them to
>> import at all in .NET):
>> __________________________
>> <message name="getArticleDetailsRequest">
>> <part name="artId" type="xsd:int"/>
>> </message>
>>
>> <message name="getArticleDetailsResponse">
>> <part name="details" type="xsd:ArrayOfString"/>
>> </message>
>> ____________
>>
>> Strange: I defined ArrayOfString, but .NET expects just string.

>
> Please post the WSDL, so we can see _how_ you defined ArrayOfString.
>
> Also, why did you define it in the "xsd" namespace? That's not your
> namespace, so you don't get to change it.
>
> Also, it doesn't look like the service is sending ArrayOfString, unless
> ArrayOfString is the same thing as ns2:Map.
> --
> John Saunders [MVP]
>


John and Steven,

thank you very much!
In Meantime i played so that the problem is slightly different.
PHP - Server works,
Can build proxy and can intellisense everything
But in VB.NET
Dim test As New de.myhandicapexpert.MyHandicapExperts

Dim res As New de.myhandicapexpert.ArticleDetailsResponse

res = test.GetArticleDetails("asdf", 3)

Return res.header

I get a nullreferenceException in the last line. So i think .NET does not
like something in the response envelope.


Here are the envelopes made with
http://www.mgateway.com/php/wsdlValidator/home.php:

i send this:
xmlns:tm='http://microsoft.com/wsdl/mime/textMatching/'
xmlns:tns='http://www.test.de/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<SOAP-ENV:Body>
<ns1:GetArticleDetails xmlns:ns1='http://www.test.de/'>
<ns1:LicenseKey xsi:type='s:string'>
fd
</ns1:LicenseKey>
<ns1:articleId xsi:type='s:int'>
3
</ns1:articleId>
</ns1:GetArticleDetails>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

*******************************************
*******************************************
and get this back:
*******************************************
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:ns1='urn:http://www.test.de/'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:ns2='http://www.test.de/'>
<SOAP-ENV:Body>
<ns2:GetArticleDetailsResponse xsi:type='ns1:ArticleDetailsResponse'>
<xsd:string>
Drittes Buch
</xsd:string>
<xsd:string>
test2
</xsd:string>
<xsd:string>
1111111
</xsd:string>
<xsd:string>
22222222222
</xsd:string>
</ns2:GetArticleDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


*******************************************
*******************************************
This is the WSDL
*******************************************

<?xml version='1.0' encoding='utf-8'?>
<wsdl:definitions
xmlns:http='http://schemas.xmlsoap.org/wsdl/http/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:s='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:tns='http://www.test.de/'
xmlns:tm='http://microsoft.com/wsdl/mime/textMatching/'
xmlns:mime='http://schemas.xmlsoap.org/wsdl/mime/'
targetNamespace='http://www.test.de/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>

<wsdl:types>
<s:schema elementFormDefault='qualified'
targetNamespace='http://www.test.de/'>

<s:element name='GetArticleDetails'>
<s:complexType>
<s:sequence>
<s:element minOccurs='1' maxOccurs='1' name='LicenseKey'
type='s:string'/>
<s:element minOccurs='1' maxOccurs='1' name='articleId'
type='s:int'/>
</s:sequence>
</s:complexType>
</s:element>


<s:element name='GetArticleDetailsResponse'>
<s:complexType>
<s:sequence>
<s:element minOccurs='1' maxOccurs='1'
name='GetArticleDetailsResult' type='tns:ArticleDetailsResponse'/>
</s:sequence>
</s:complexType>
</s:element>


<s:complexType name='ArticleDetailsResponse'>
<s:sequence>
<s:element minOccurs='1' maxOccurs='1' name='title'
type='s:string'/>
<s:element minOccurs='1' maxOccurs='1' name='header'
type='s:string'/>
<s:element minOccurs='1' maxOccurs='1' name='test1'
type='s:string'/>
<s:element minOccurs='1' maxOccurs='1' name='test2'
type='s:string'/>
</s:sequence>
</s:complexType>


</s:schema>
</wsdl:types>

<wsdl:message name='GetArticleDetailsSoapIn'>
<wsdl:part name='parameters' element='tns:GetArticleDetails'/>
</wsdl:message>

<wsdl:message name='GetArticleDetailsSoapOut'>
<wsdl:part name='parameters' element='tns:GetArticleDetailsResponse'/>
</wsdl:message>

<wsdl:portType name='MyHandicapExpertsSoap'>

<wsdl:operation name='GetArticleDetails'>
<documentation xmlns='http://schemas.xmlsoap.org/wsdl/'>
Gives the currency exchange rate between the two currencies.
</documentation>

<wsdl:input message='tns:GetArticleDetailsSoapIn'/>
<wsdl:output message='tns:GetArticleDetailsSoapOut'/>
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name='MyHandicapExpertsSoap'
type='tns:MyHandicapExpertsSoap'>
<soap:binding transport='http://schemas.xmlsoap.org/soap/http'
style='document'/>

<wsdl:operation name='GetArticleDetails'>
<soap:operation soapAction='http://www.test.de/GetArticleDetails'
style='document'/>

<wsdl:input>
<soap:body use='literal'/>
</wsdl:input>

<wsdl:output>
<soap:body use='literal'/>
</wsdl:output>
</wsdl:operation>

</wsdl:binding>
<wsdl:service name='MyHandicapExperts'>
<documentation xmlns='http://schemas.xmlsoap.org/wsdl/'>
My Handicap Experts Database
</documentation>

<wsdl:port name='MyHandicapExpertsSoap'
binding='tns:MyHandicapExpertsSoap'>
<soap:address
location='http://test.de/expertdbws/main/mhdwissen_main.php'/>
</wsdl:port>

</wsdl:service>
</wsdl:definitions>
*******************************************
*******************************************

Thank you again!
Dirk



msdnuniv 08-24-2007 10:49 AM

Re: exception on Response Envelope, Error in XML-document
 
Hello All,

i can narrow it down a bit (replaced my URL and NS with "test"):
This is the VB.NET code, which builds and intellisense is showing all types
correctly:

Public Function getArtDet() As String
Dim test As New de.test.MyHandicapExperts
Dim res As New de.test.ArticleDetailsResponse
Dim header As String

res = test.GetArticleDetails("asdf", 3)
header = res.header

Return header
End Function
I get a nullreferenceException on
header = res.header

i proved with wireshark and i am sure there is a correctly looking envelope
coming back (see below).
What is wrong with it and what can i do to consume this webservice?
Thank you!
Dirk

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:ns1='urn:http://www.test.de/'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:ns2='http://www.test.de/'>
<SOAP-ENV:Body>
<ns2:GetArticleDetailsResponse xsi:type='ns1:ArticleDetailsResponse'>
<xsd:string>
Drittes Buch
</xsd:string>
<xsd:string>
Viertes Kapitel
</xsd:string>
<xsd:string>
adsf
</xsd:string>
<xsd:string>
adfsdaf
</xsd:string>
</ns2:GetArticleDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>





msdnuniv 08-24-2007 11:20 AM

Re: exception on Response Envelope, Error in XML-document
 
"msdnuniv" <dm4dm@newsgroup.nospam> schrieb im Newsbeitrag
news:Od49oxj5HHA.3916@TK2MSFTNGP02.phx.gbl...
> Hello All,
>
> i can narrow it down a bit (replaced my URL and NS with "test"):
> This is the VB.NET code, which builds and intellisense is showing all
> types correctly:
>
> Public Function getArtDet() As String
> Dim test As New de.test.MyHandicapExperts
> Dim res As New de.test.ArticleDetailsResponse
> Dim header As String
>
> res = test.GetArticleDetails("asdf", 3)
> header = res.header
>
> Return header
> End Function
> I get a nullreferenceException on
> header = res.header
>
> i proved with wireshark and i am sure there is a correctly looking
> envelope coming back (see below).
> What is wrong with it and what can i do to consume this webservice?
> Thank you!
> Dirk
>
> <?xml version='1.0' encoding='UTF-8'?>
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
> xmlns:ns1='urn:http://www.test.de/'
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
> xmlns:ns2='http://www.test.de/'>
> <SOAP-ENV:Body>
> <ns2:GetArticleDetailsResponse xsi:type='ns1:ArticleDetailsResponse'>
> <xsd:string>
> Drittes Buch
> </xsd:string>
> <xsd:string>
> Viertes Kapitel
> </xsd:string>
> <xsd:string>
> adsf
> </xsd:string>
> <xsd:string>
> adfsdaf
> </xsd:string>
> </ns2:GetArticleDetailsResponse>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>


Hello again,

now i have an alternative response - envelope, but with exactly the same
result:
(It has tags for the element names instead of </xsd:string>)
What can i try to debug it in VB.NET? Where can i see what the proxy-class
does? BTW: I do not find the proxy class in my project. I can create my own
with wsdl.exe but i do not find the one created on adding the webservice...
Please can anybody help? I'm working on this since 60 hours now and could
not get one step further.
Dirk

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:ns1='urn:http://www.test.de/'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:ns2='http://www.test.de/'>
<SOAP-ENV:Body>
<ns2:GetArticleDetailsResponse xsi:type='ns1:ArticleDetailsResponse'>
<title>
Drittes Buch
</title>
<header>
Viertes Kapitel
</header>
<test1>
adsf
</test1>
<test2>
adfsdaf
</test2>
</ns2:GetArticleDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>



msdnuniv 08-24-2007 12:07 PM

Re: exception on Response Envelope, Error in XML-document
 
> Public Function getArtDet() As String
> Dim test As New de.test.MyHandicapExperts
> Dim res As New de.test.ArticleDetailsResponse
> Dim header As String
>
> res = test.GetArticleDetails("asdf", 3)
> header = res.header
>
> Return header
> End Function
> I get a nullreferenceException on
> header = res.header


one more silly thing:
Please can somebody explain, why i get no Exception
in first line
and after invoking GetArticleDetails i get an exception in third line?
- - - - - - - - - - - - - - - - -
'This is OK:
myHash = resType.GetHashCode

'This is OK:
res = test.GetArticleDetails("adsf", 3)

'NullReferenceException here:
myHash = resType.GetHashCode
- - - - - - - - - - - - - - - - -

Thank you!
Dirk



John Saunders [MVP] 08-24-2007 05:27 PM

Re: exception on Response Envelope, Error in XML-document
 
"msdnuniv" <dm4dm@newsgroup.nospam> wrote in message
news:OstGZdk5HHA.1212@TK2MSFTNGP05.phx.gbl...
>> Public Function getArtDet() As String
>> Dim test As New de.test.MyHandicapExperts
>> Dim res As New de.test.ArticleDetailsResponse
>> Dim header As String
>>
>> res = test.GetArticleDetails("asdf", 3)
>> header = res.header
>>
>> Return header
>> End Function
>> I get a nullreferenceException on
>> header = res.header

>
> one more silly thing:
> Please can somebody explain, why i get no Exception
> in first line
> and after invoking GetArticleDetails i get an exception in third line?
> - - - - - - - - - - - - - - - - -
> 'This is OK:
> myHash = resType.GetHashCode
>
> 'This is OK:
> res = test.GetArticleDetails("adsf", 3)
>
> 'NullReferenceException here:
> myHash = resType.GetHashCode
> - - - - - - - - - - - - - - - - -


If you comment out that second "GetHashCode" line, what happens?
--
John Saunders [MVP]


msdnuniv 08-25-2007 03:06 PM

Re: exception on Response Envelope, Error in XML-document
 

"John Saunders [MVP]" <john.saunders at trizetto.com> schrieb im Newsbeitrag
news:%23XqWYQn5HHA.5160@TK2MSFTNGP05.phx.gbl...
> "msdnuniv" <dm4dm@newsgroup.nospam> wrote in message
> news:OstGZdk5HHA.1212@TK2MSFTNGP05.phx.gbl...
>>> Public Function getArtDet() As String
>>> Dim test As New de.test.MyHandicapExperts
>>> Dim res As New de.test.ArticleDetailsResponse
>>> Dim header As String
>>>
>>> res = test.GetArticleDetails("asdf", 3)
>>> header = res.header
>>>
>>> Return header
>>> End Function
>>> I get a nullreferenceException on
>>> header = res.header

>>
>> one more silly thing:
>> Please can somebody explain, why i get no Exception
>> in first line
>> and after invoking GetArticleDetails i get an exception in third line?
>> - - - - - - - - - - - - - - - - -
>> 'This is OK:
>> myHash = resType.GetHashCode
>>
>> 'This is OK:
>> res = test.GetArticleDetails("adsf", 3)
>>
>> 'NullReferenceException here:
>> myHash = resType.GetHashCode
>> - - - - - - - - - - - - - - - - -

>
> If you comment out that second "GetHashCode" line, what happens?
> --
> John Saunders [MVP]


John,

then there is no exception :-)
I do not need GetHashCode. I try to say that I can't do anything with
resType anymore after i called the function GetArticleDetails(). This works
too. But if i try to get one of its members afterwards (and even if it is
the trivial GetHashCode), I get that exception at runtime.

Greetings,
Dirk



John Saunders [MVP] 08-26-2007 12:29 AM

Re: exception on Response Envelope, Error in XML-document
 
"msdnuniv" <dm4dm@newsgroup.nospam> wrote in message
news:%238ansly5HHA.5980@TK2MSFTNGP04.phx.gbl...
>
> "John Saunders [MVP]" <john.saunders at trizetto.com> schrieb im
> Newsbeitrag news:%23XqWYQn5HHA.5160@TK2MSFTNGP05.phx.gbl...
>> "msdnuniv" <dm4dm@newsgroup.nospam> wrote in message
>> news:OstGZdk5HHA.1212@TK2MSFTNGP05.phx.gbl...
>>>> Public Function getArtDet() As String
>>>> Dim test As New de.test.MyHandicapExperts
>>>> Dim res As New de.test.ArticleDetailsResponse
>>>> Dim header As String
>>>>
>>>> res = test.GetArticleDetails("asdf", 3)
>>>> header = res.header
>>>>
>>>> Return header
>>>> End Function
>>>> I get a nullreferenceException on
>>>> header = res.header
>>>
>>> one more silly thing:
>>> Please can somebody explain, why i get no Exception
>>> in first line
>>> and after invoking GetArticleDetails i get an exception in third line?
>>> - - - - - - - - - - - - - - - - -
>>> 'This is OK:
>>> myHash = resType.GetHashCode
>>>
>>> 'This is OK:
>>> res = test.GetArticleDetails("adsf", 3)
>>>
>>> 'NullReferenceException here:
>>> myHash = resType.GetHashCode
>>> - - - - - - - - - - - - - - - - -

>>
>> If you comment out that second "GetHashCode" line, what happens?
>> --
>> John Saunders [MVP]

>
> John,
>
> then there is no exception :-)


Ok, you haven't shown us the relationship between res and resType. Please
show us how they are declared.

Also, try simplifying this a bit:

res = Nothing 'test.GetArticleDetails("adsf", 3)

See what happens (include the second GetHashCode!)
--
John Saunders [MVP]




All times are GMT. The time now is 10:00 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.