View Full Version : ASP.NET Anyone?
Has anyone developed with the ShopWindow API using ASP.NET / VB.NET? I can get as far as adding a web reference to my project, making a call to the webservice, getting a response, but cannot see the actual "Product" object that is mentioned in the documentation. I have an "ArrayOfProduct", but Visual Studio says it "cannot be indexed because it has no default property" when I try to loop through it. I can't see the Product in object explorer either. Guess I'm missing something fundamental...
Jack,
I had the same issues with missing data types and user defined objects and being new to all these technologies (soap,wsdl etc) it has been a steep learning curve getting the classes right for .Net. . You've got your work cut out to make this work, if you know PHP (I don't) then look into getting that installed and use the client as that will speed up development 10 fold also you'll get a lot of help here in the forum, anyway if like me your forced to use .Net then here's my take on the problem and the approach I took.
Background: (forgive me if you already know this)
When you add a web reference to Visual Studio a lot is happening on-the-fly, a discomap is created (disco.exe) which discovers the web service, a wsdl file is created from the discomap. The wsdl file is proccessed by wsdl.exe and a proxy class file is created using code dom and compiled, this is a resultant apiservice.dll.
Unfortunately wsdl.exe has a few limitations the main problem being the way it interprets arrays and array types. Look at this excerpt from the wsdl file
<complexType name="ArrayOfProduct">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="api:Product[]" />
</restriction>
</complexContent>
</complexType>
I have highlighted the reference to soapenc:arrayType and wsdl:arrayType note that although this is a perfectly valid method of defining a user defined array within soap wsdl.exe cannot interpret it. As far as wsdl.exe is concerned it doesn't understand wsdl:arrayType, therefore the object it refers to is not included in the generated code which is why you cannot find product in the class. If you look at ArrayOf Product you will notice it just inherits from array. You can with some tweaks delve into the 'innerhtml' of this object to get to the products but really it needs to be an object you can easily work with and bind controls to.It took me ages to get my head round this and come up with a work around.
What I did was to create my own .Net friendly wsdl file, I replaced all of the references using wsdl:ArrayType with
<complex type name=ArrayOfProduct>
<sequence MinOccurs=0 MaxOccurs=Unbounded>
<element name=Product type=Product>
</sequence>
</complexType>
I then used wsdl.exe to manually create a proxyclass file. I then edited this file and changed all of the generic partial classes to inherit from the types I needed, for example I made ArrayOfProduct a collection with a single property called Product , this type of collection is IE-Enumerable which means I can bind it to most controls.
Perhaps AW could look into producing .Net friendly versions of the wsdl files which avoids the use of wsdl:ArrayType and just uses sequences, there maybe a better approach to this but like I said I'm new to all this.
If you decide to go down this route then I would advise reading up on the soap/xml/wsdl schema and have a go at creating your own wsdl, this way you will gain a much better understanding of whats going on under-the-hood.
Hope that helped
Jon
Thanks for the detailed reply. Looks like the .NET guys are in a minority here! I don't do PHP, I use ASP.NET 2.0 out of choice.
It's a real pain that the wsdl doesn't quite work with .NET, it's not a problem I've come across before. The Amazon web service wsdl works a treat for example.
I've got Shop Window up and running now by looping through the searchProductResponse, getting the InnerText of the nodes I want, creating rows in a datable and then binding to that, but it's not really ideal is it - it's not a "Product" object. Anyway, maybe its something that AW will think about in an upgrade...
Any help would be appreciate here. I've got the wsdl ready but having problems after that.