using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;using
System.Net;using
TestShop; public partial class _Default : System.Web.UI.Page{
string url = "http://link/CatalogueService"; string username = "username"; string password = "password"; int shopcode = 1;protected void Page_Load(object sender, EventArgs e)
{
CatalogueService catserv = new AuthorizingCatalogueService();catserv.PreAuthenticate =
true;catserv.Credentials =
new NetworkCredential(username,password);catserv.Url = url ;
try{
Item item = new Item(); int b = item.wallpapers.Length; for (int i = 0; i < b; b--){
Label1.Text += item.wallpapers
.id.ToString();
}
}
catch (Exception d){
Label2.Text = d.ToString();
Label1.Text =
"";}
}
}
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
//
// This source code was auto-generated by wsdl, Version=1.1.4322.2032.
//
namespace
TestShop { using System.Diagnostics; using System.Xml.Serialization; using System; using System.Web.Services.Protocols; using System.ComponentModel; using System.Web.Services; /// <remarks/>[System.Diagnostics.
DebuggerStepThroughAttribute()][System.ComponentModel.
DesignerCategoryAttribute("code")][System.Web.Services.
WebServiceBindingAttribute(Name="CatalogueServiceSoapBinding", Namespace="http:///CatalogueService")][System.Xml.Serialization.
SoapIncludeAttribute(typeof(WallpaperProduct))][System.Xml.Serialization.
SoapIncludeAttribute(typeof(Wallpaper))][System.Xml.Serialization.
SoapIncludeAttribute(typeof(RingtoneProduct))][System.Xml.Serialization.
SoapIncludeAttribute(typeof(ArtistAndRole))][System.Xml.Serialization.
SoapIncludeAttribute(typeof(Ringtone))][System.Xml.Serialization.
SoapIncludeAttribute(typeof(Item))] public class CatalogueService : System.Web.Services.Protocols.SoapHttpClientProtocol { /// <remarks/> public CatalogueService() { this.Url = "http:///CatalogueService";}
/// <remarks/>[System.Web.Services.Protocols.
SoapRpcMethodAttribute("", RequestNamespace="http://CatalogueService", ResponseNamespace="http:///CatalogueService")] public void resetCatalogue(int shopCode) { this.Invoke("resetCatalogue", new object[] {shopCode});
}
/// <remarks/> public System.IAsyncResult BeginresetCatalogue(int shopCode, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("resetCatalogue", new object[] {shopCode}, callback, asyncState);
}
/// <remarks/> public void EndresetCatalogue(System.IAsyncResult asyncResult) { this.EndInvoke(asyncResult);}
/// <remarks/>[System.Web.Services.Protocols.
SoapRpcMethodAttribute("", RequestNamespace="http://CatalogueService", ResponseNamespace="http://CatalogueService")][
return: System.Xml.Serialization.SoapElementAttribute("getCatalogueUpdatesReturn")] public Item[] getCatalogueUpdates(int shopCode) { object[] results = this.Invoke("getCatalogueUpdates", new object[] {shopCode});
return ((Item[])(results[0]));}
/// <remarks/> public System.IAsyncResult BegingetCatalogueUpdates(int shopCode, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("getCatalogueUpdates", new object[] {shopCode}, callback, asyncState);
}
/// <remarks/> public Item[] EndgetCatalogueUpdates(System.IAsyncResult asyncResult) { object[] results = this.EndInvoke(asyncResult); return ((Item[])(results[0]));}
}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("Item", "http:///CatalogueService")] public class Item { /// <remarks/> public Album album; /// <remarks/> public Category category; /// <remarks/> public int id; /// <remarks/> public string name; /// <remarks/> public Ringtone[] ringtones; /// <remarks/> public Wallpaper[] wallpapers;}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("Album", "http:///CatalogueService")] public class Album { /// <remarks/> public int id; /// <remarks/> public string labelName; /// <remarks/> public string name; /// <remarks/> public Album parent; /// <remarks/> public int tracks; /// <remarks/> public string vendorName;}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("WallpaperProduct", "http:///CatalogueService")] public class WallpaperProduct { /// <remarks/> public int colorDepth; /// <remarks/> public string currency; /// <remarks/> public int dpi; /// <remarks/> public int height; /// <remarks/> public int id; /// <remarks/> public bool preview; /// <remarks/> public string previewUrl; /// <remarks/> public int priceInCents; /// <remarks/> public string productId; /// <remarks/> public string type; /// <remarks/> public int width;}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("Wallpaper", "http:///CatalogueService")] public class Wallpaper { /// <remarks/> public ArtistAndRole[] artistsAndRoles; /// <remarks/> public int id; /// <remarks/> public WallpaperProduct[] wallpaperProducts;}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("ArtistAndRole", "http:///CatalogueService")] public class ArtistAndRole { /// <remarks/> public Artist artist; /// <remarks/> public ArtistRole artistRole;}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("Artist", "http:///CatalogueService")] public class Artist { /// <remarks/> public int id; /// <remarks/> public string name; /// <remarks/> public string type;}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("ArtistRole", "http:///CatalogueService")] public class ArtistRole { /// <remarks/> public int id; /// <remarks/> public string name;}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("RingtoneProduct", "http:///CatalogueService")] public class RingtoneProduct { /// <remarks/> public string bitrate; /// <remarks/> public string currency; /// <remarks/> public string duration; /// <remarks/> public int id; /// <remarks/> public bool preview; /// <remarks/> public string previewUrl; /// <remarks/> public int priceInCents; /// <remarks/> public string productId; /// <remarks/> public string type;}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("Ringtone", "http://CatalogueService")] public class Ringtone { /// <remarks/> public ArtistAndRole[] artistsAndRoles; /// <remarks/> public System.DateTime creationDate; /// <remarks/> public int id; /// <remarks/> public RingtoneProduct[] ringtoneProducts;}
/// <remarks/>[System.Xml.Serialization.
SoapTypeAttribute("Category", "http://CatalogueService")] public class Category { /// <remarks/> public int id; /// <remarks/> public string name; /// <remarks/> public Category parent;}
}

I could really do with a pointer in the right direction
danrhee
I certainly don’t want you to do anything that could in anyway get fired, unfortunately based on what information I have here at hand (and my inability to access the URL you gave) I do not have enough information with which to help you fix your problem.
My overall advice remains the same, make sure you are properly calling the web service and in the process creating an instance your data stores.
The line:
Item item = new Item();
seems nice and safe however my bet would be you need to use catserv to populate it, not just create a new instance yourself.
Nestos
thanx for your reply
the idea is to collect a catalogue of artists,ringtones etc through a webservice
my problem was that i can.t get any items from the class item
[System.Xml.Serialization.SoapTypeAttribute("Item", "http:///CatalogueService")]
public class Item {
/// <remarks/>
public Album album; /// <remarks/> public Category category; /// <remarks/> public int id; /// <remarks/> public string name; /// <remarks/> public Ringtone[] ringtones; /// <remarks/> public Wallpaper[] wallpapers;}
but i think i know now where i went wrong
i assume i have to make a array of objects first before being able to call wallpaper or ringtone or whatever
Daniel Chu
http://arvatoportal.chess-it.com/mmplatform/services/CatalogueService wsdl
sorry this is the right link
Gustavo Valdes
na the connection to the webservice is fine
it is a axis webservice but because .net never sends authentication on the first try but only after receiving a 403 status from the server
but this server (apache) doesnot send a 403 but raises an error if a user is not logged in
so i wrote a helper class called AuthorizingCatalogueService it inherits CatalogueService
it logs in to the server and i get the lenght of the Item array back but when i want to get to the data by trying this forexample item.Wallpaper it gives me the error that I have to use the new keyword
but if i try to create a array and allocate item.Wallpaper to it tells me that item is not known
the wsdl for this service you can find on http://www.arvatoportal.chess-it.com/mmplatform/services/Catalogueservice wsdl
can not give any passwords sorry I would be fired
rw-ral
thanx for your replies
you gave me some fresh ideas
and yes i am tryimg to talk to the makers of this webservice for a while now but they do not want to talk directly so i have to talk to this young women who has no clue of programming and she has to convey my message to them
in an ideal world i would be able to get the objects out by declaring something like this
item[] item = new catalogueService().Walpaper()
but they have created arrays like three to four deep sometimes
but my mean problem is that it will not authenticate if i do it like that so
thanx anyway
BlueLou
yes i did there is a method called getCatalogueUpdates(shopid)
it returns objects of type Item[] (which is also a class in the CatalogueService)
so I call catserv.getCatalogueUpdates(shopid) if I try to retrieve the any item it tell me that i have to use the new keyword
but again if i try to allocate it to an array i have initialized it tells me that catserv is not a namespace but that is the part that messes me up because i have created a catserv object already
i just tried the link too and i could not get on it from home so i will find a different way to send you the wsdl file
HopeDreamsComeTrue
using
System;using
System.Net;using
System.Text;///
<summary>///
Summary description for AuthorizingOrderService///
</summary>namespace
TestShop{
public class AuthorizingCatalogueService : CatalogueService{
protected override WebRequest GetWebRequest(Uri uri){
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri); if (this.PreAuthenticate){
NetworkCredential nc = this.Credentials.GetCredential(uri, "Basic"); if (nc != null){
byte[] credBuf = new UTF8Encoding().GetBytes(nc.UserName + ":" + nc.Password);request.Headers[
"Authorization"] = "Basic " + Convert.ToBase64String(credBuf);}
}
return request;}
}
}
dlettier
First up, in future I would suggest directing ASP.NET related questions to the official ASP.NET forums.
Now then… if my counting is correct line 31 comes out to be this line:
Label1.Text += item.wallpapers
.id.ToString();
Coupled with the for statement above I am puzzled by exactly what you are trying to do... iterating through each item in your wall paper list is fine... but what you’ve got right now will not do that, you’ll get through roughly half of your list (the upper half)
For a start I would suggest changing your for loop to be something more along the lines of:
for (int i = item.wallpapers.Length; i >= 0; i--)
.id.ToString();
{
Label1.Text += item.wallpapers
}
This way you still iterate through your list in reverse order, only now you make it through the whole thing (provided there are no issues).
Finally, rather than just assuming that you are going to get a valid item out of your wallpapers property array, you may want to capture it and do a little checking on it to make sure that it is not null as well as it’s id property is not null before calling ToString() on it.
CarlosHere
Eeek, I missed that bit. You are correct, in order to be able to use an array you must first explicitly create it, in your constructor for the Item class you are creating a reference to such an array but not an actual one.
Once you’ve got your actual array the next part is creating objects within it.
Zak (ilm)
All I can really suggest is making sure you know how to access a web service and that you are accessing it in an appropriate way. From what I can tell of your code you are not currently doing so however I could be wrong.
For starters... do you have a reference to the web service in question
Nestor N
With that example it seems pretty clear that your call to getCatalogueUpdates is returning null for null an array and as such does not have the Length property available.
Right before your for loop you could put:
If( item == null )
{
Label2.Text = “Null Array Received”;
return;
}
So that if you are aware of this fact… sadly this does keep looking more and more like an issues either with the web service or the data you are giving it... is shopcode a valid value for this WS
Lastly... it may be time to talk to the makers or supporters of this web service as I am fresh out of ideas.
in-q-ztiv
did this
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using TestShop;
public partial class _Default : System.Web.UI.Page
{
string url = "http://217.166.48.179/mmplatform/services/CatalogueService";
string username = "";
string password = "";
int shopcode = ;
protected void Page_Load(object sender, EventArgs e)
{
CatalogueService catserv = new AuthorizingCatalogueService();
catserv.PreAuthenticate = true;
catserv.Credentials = new NetworkCredential(username,password);
catserv.Url = url ;
try
{
int num = 0;
Item[] item = catserv.getCatalogueUpdates(shopcode);
line 31: for (int i = item.Length; i > 0; i--)
{
num++;
}
Label1.Text = num.ToString();
}
catch (Exception d)
{
Label2.Text = d.ToString();
Label1.Text = "";
}
}
}
got this error:
System.NullReferenceException: Object reference not set to an instance of an object. at _Default.Page_Load(Object sender, EventArgs e) in \\newton\user docs\JHennep\My Documents\Visual Studio 2005\WebSites\arvato\Default.aspx.cs:line 31
cologsx
yes and that is where i fail :(
so if you have any ideas i would be so happy i have been strugling with this thing for a week now, the people that created the service are no help at all
by the way I just looked at my for loop again and now i see how idiotic it is haha this has all to do with the stress this job is causing me
Arun Narayan
That looks better... yes... it appears that to populate your item array you need to call getCatalogUpdates ala (where you supply a value for shopCode):
Item[] item = cs.getCatalogueUpdates( shopCode );
This does not address the issue of making sure your are properly authenticated however.