exception on Response Envelope, Error in XML-document

M

msdnuniv

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
 
J

John Saunders [MVP]

msdnuniv said:
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.
 
S

Steven Cheng[MSFT]

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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.

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


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

msdnuniv

Hello!
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 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:eek:peration 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:eek:utput message='tns:GetArticleDetailsSoapOut'/>
</wsdl:eek:peration>
</wsdl:portType>

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

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

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

<wsdl:eek:utput>
<soap:body use='literal'/>
</wsdl:eek:utput>
</wsdl:eek:peration>

</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
 
M

msdnuniv

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>
 
M

msdnuniv

msdnuniv said:
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>
 
M

msdnuniv

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
 
J

John Saunders [MVP]

msdnuniv said:
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?
 
M

msdnuniv

John Saunders said:
If you comment out that second "GetHashCode" line, what happens?

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
 
J

John Saunders [MVP]

msdnuniv said:
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!)
 
S

Steven Cheng[MSFT]

Hi Dirk,

Yes, as John said, would you show us the relationship between the resType
and the proxy object(test), from the code snippet it really unexpected to
get such a result.

Also, for the proxy class code question you mentioned earlier, have you
found it? For the proxy generated by "Add WebReference in VS IDE", you can
view it as below:

** if the proxy class is generated in winform or console or class library
project, you can select and click the certain webreference node in solution
explorer(or expand the node) to find the autogenerated xxx.designer.cs(or
vb) file. The code of the proxy is in it.

** For ASP.NET web project(not web application project), the proxy code is
dynamically generated and compiled, so you can not find any pregenerated
code in project folder at design-time. Also, the autogenerated code mainly
contains some class and method definition and does not contain any info
about the underlying XML processing.

BTW, is there an external URL we can visit and test?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


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




--------------------
From: "John Saunders [MVP]" <john.saunders at trizetto.com>
References: <[email protected]>
<[email protected]>
<[email protected]>
 
K

Kim Janssens

Hello,

I am having the same problem as you. It would be really a big help if you could give me some insights if you were able to manage to find a solution for this problem?

Great thanks

Kim
 

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

Members online

No members online now.

Forum statistics

Threads
473,930
Messages
2,570,072
Members
46,522
Latest member
Mad-Ram

Latest Threads

Top