开发者

How to retrieve a collection out of an SOAP message

开发者 https://www.devze.com 2023-02-10 07:59 出处:网络
I\'m using a webservice for render company information based on a special company number. But i can not get data out of the response SOAP message.

I'm using a webservice for render company information based on a special company number. But i can not get data out of the response SOAP message. You can see an example of the response soap message. (I left out some company information the tags).

<?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:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<businessGetDossierV3Response xmlns="http://www.webservices.nl/soap/">
<out>
<paging>
<curpage>1</curpage>
<perpage>10</perpage>
<numpages>1</numpages>
<numresults>1</numresults>
<maxresults>100</maxresults>
</paging>
<results>
<item>
<DossierNo></DossierNo>
<SubDossierNo></SubDossierNo>
<ChamberNo></ChamberNo>
<Legalformcode></Legalformcode>
<LegalformcodeText></LegalformcodeText>
<Tradename45></Tradename45>
<EstablishmentPostcode></EstablishmentPostcode>
<EstablishmentCity></EstablishmentCity>
<EstablishmentStreetname></EstablishmentStreetname>
<EstablishmentHouseNo></EstablishmentHouseNo>
<CorrespondencePostcode></CorrespondencePostcode>开发者_运维技巧;
<CorrespondenceCity></CorrespondenceCity>
<CorrespondenceStreetname></CorrespondenceStreetname>
<CorrespondenceHouseNo></CorrespondenceHouseNo>
</item>
</results>
</out>
</businessGetDossierV3Response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

! this is the result i see on the demo client ! But this is my code in C#

        nl.webservices.ws1.BusinessDossierV3PagedResult result = null;
        result = myserviceBusiness.businessGetDossierV3(KVKnr, "0000", 1);

I want to do something like this (but with the results instead of paging part)

int page = result.paging.numpages;

Then I should be like this I suppose

string city = result.results.item.CorrespondenceCity;

But this is giving a fault message

So in Visual studio 2010, i can only retrieve the data in the paging part of the xml and put it into a textbox, but not from results part. Is this because the result part is some kind of Collection?

So yes, how can i put the data from the tags EstablishmentPostcode and EstablishmentCity in a textbox on my default page?

thanks in advance


You could try adding your SOAP service as a web reference to the project. http://msdn.microsoft.com/en-us/library/tydxdyw9.aspx

If you don't want to do this and would rather work on the XML directly you could use xpath to get access to all the item elements in your results element. http://www.stardeveloper.com/articles/display.html?article=2009031001&page=1

One thing to be careful of when using xpath is that you use the correct xml namespace for the node you're trying to select.

Ben

0

精彩评论

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

关注公众号