Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2006

Tip: Looking for answers? Try searching our database.

Namespace confusion

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bonacipher - 02 Feb 2006 14:53 GMT
I've been given a wsdl file, and used the the WSDL.exe generator to make a
proxy file. I've then added the code for the web method, and compiled and all
is fine. I had to add in a load of namespaces for the web service to work
properly, but there is still an underlying problem. If I send it an XML file
with

<tns:Sales Order>

it doesn't work - I get an "Object reference not set to an instance of an
object". However if I send it <Sales Order> then this is fine. Sorry, I
realise my grasp on this is pretty weak, but have come up against a brick
wall. I've pasted in the code below.

Many thanks in advance.

------------------

namespace Warehouse
{
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
using Warehouse.Code.BLL;
using Warehouse.Code.DAL;
   
/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute (Name="FulfilOrderBinding",
Namespace="http://www.deloitte.co.uk/soademo/services/warehouse")]

[WebService(Namespace=" http://www.deloitte.co.uk/soademo/messages")]
public class FulfilOrderService :  System.Web.Services.Protocols.
SoapHttpClientProtocol
{
 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("replace with
soap operation url", Use= System.Web.Services.Description.SoapBindingUse.
Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)
]
 [return: System.Xml.Serialization.XmlElementAttribute
("FulfilmentRequestSummary", Namespace="
http://www.deloitte.co.uk/soademo/messages")]
 
 [WebMethod]
 public FulfilmentRequestType FulfilOrder([System.Xml.Serialization.
XmlElementAttribute (Namespace="http://www.deloitte.co.uk/soademo/messages")]
SalesOrderType SalesOrder)
 {
  FulfilmentRequestType fulfilmentRequest;
  int fulfilmentRequestID;
  int statusID;
  bool sufficientStock = true;
  SQLDataAccessLayer dataAccessObject = new SQLDataAccessLayer();
  fulfilmentRequest  = new FulfilmentRequestType();
 
  for(int i=0; i<SalesOrder.lineItems.Length ; i++)
  {
   int productID = SalesOrder.lineItems[i].productID;
   int quantity = SalesOrder.lineItems[i].quantity;
   if(!dataAccessObject.isStockSufficient(productID,quantity))
   {
    sufficientStock=false;
   }
  }
  int orderID = SalesOrder.orderID;
  if(sufficientStock)
  {
   statusID = Globals.UNFULFILLED;
   fulfilmentRequestID = dataAccessObject.GenerateFulfilmentRequest(orderID,
statusID);
   fulfilmentRequest.fulfilmentRequestID = fulfilmentRequestID;
   // this code has been superseded:
   // the shipping request ID is appended to the end of the fulfilment
request ID
   // so we need to remove the prefix: FFyyyymmdd (10 chars, so remove from
index 11)
   //int fulfilmentRequestID = Int32.Parse(fulfilmentRequestID.Substring(10))
;
   for(int i=0; i<SalesOrder.lineItems.Length; i++)
   {
    int productID = SalesOrder.lineItems[i].productID;
    int quantity = SalesOrder.lineItems[i].quantity;
    dataAccessObject.ReduceStock(productID, quantity);
    int orderLineNo = i+1;
    dataAccessObject.InsertOrderline(orderID, productID, fulfilmentRequestID,
orderLineNo, quantity);
   }
  }
  else
  {
   statusID = Globals.INSUFFICIENT;
   //fulfilmentRequestID = dataAccessObject.GenerateFulfilmentRequest
(orderID,statusID);
  }
 
  fulfilmentRequest.dateCreated = DateTime.Now;
  fulfilmentRequest.status =  statusID.ToString();
  return fulfilmentRequest;
 }
       
 /// <remarks/>
 public System.IAsyncResult BeginFulfilOrder(SalesOrderType SalesOrder,
System.AsyncCallback callback, object asyncState)
 {
  return this.BeginInvoke("FulfilOrder", new object[] {
                SalesOrder}, callback, asyncState);
 }
       
 /// <remarks/>
 public FulfilmentRequestType EndFulfilOrder(System.IAsyncResult asyncResult)

 {
  object[] results = this.EndInvoke(asyncResult);
  return ((FulfilmentRequestType)(results[0]));
 }
}
   
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="
http://www.deloitte.co.uk/soademo/messages")]
public class SalesOrderType
{
       
 /// <remarks/>
 public int orderID;
       
 /// <remarks/>
 public System.DateTime dateCreated;
       
 /// <remarks/>
 public string status;
       
 /// <remarks/>
 public CustomerType customer;
       
 /// <remarks/>
 [System.Xml.Serialization.XmlArrayAttribute(Namespace="
http://www.deloitte.co.uk/soademo/messages ")]
 [System.Xml.Serialization.XmlArrayItemAttribute("lineItem", Namespace="
http://www.deloitte.co.uk/soademo/messages", IsNullable=false)]
 public LineItemType[] lineItems;
       
 /// <remarks/>
 [System.Xml.Serialization.XmlElementAttribute(Namespace="
http://www.deloitte.co.uk/soademo/messages ")]
 public AddressType shipToAddress;
       
 /// <remarks/>
 [System.Xml.Serialization.XmlElementAttribute(Namespace="
http://www.deloitte.co.uk/soademo/messages ")]
 public AddressType billToAddress;
}
   
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="
http://www.deloitte.co.uk/soademo/messages ")]
public class CustomerType
{
       
 /// <remarks/>
 public int customerID;
       
 /// <remarks/>
 public string title;
       
 /// <remarks/>
 public string initial;
       
 /// <remarks/>
 public string familyName;
       
 /// <remarks/>
 public string emailAddress;
       
 /// <remarks/>
 public string homeTelephoneNo;
       
 /// <remarks/>
 public string mobileTelephoneNo;
       
 /// <remarks/>
 public string notificationChannel;
       
 /// <remarks/>
 public string notificationFormat;
}
   
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="
http://www.deloitte.co.uk/soademo/messages")]
public class FulfilmentRequestType
{
       
 /// <remarks/>
 public int fulfilmentRequestID;
       
 /// <remarks/>
 public string orderID;
       
 /// <remarks/>
 public System.DateTime dateCreated;
       
 /// <remarks/>
 public string status;
}
   
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="
http://www.deloitte.co.uk/soademo/messages")]
public class AddressType
{
       
 /// <remarks/>
 public string addressLine1;
       
 /// <remarks/>
 public string addressLine2;
       
 /// <remarks/>
 public string addressLine3;
       
 /// <remarks/>
 public string addressLine4;
       
 /// <remarks/>
 public string postcode;
}
   
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="
http://www.deloitte.co.uk/soademo/messages")]
public class LineItemType
{
       
 /// <remarks/>
 public int orderLineNo;
       
 /// <remarks/>
 public int productID;
       
 /// <remarks/>
 public int quantity;
}
}
Javier G. Lozano - 03 Feb 2006 17:08 GMT
Where are you sending the XML file containing "<tns:Sales Order>"?
bonacipher - 07 Feb 2006 16:02 GMT
I'm sending it to this .NET web service fulfilOrder (the end point defined
within the WSDL.)
I think it goes to fulfilOrderService.asmx to be precise. Is that what you
mean?

thanks
Mike

>Where are you sending the XML file containing "<tns:Sales Order>"?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.