I've created an asmx web service to handle an outbound message from Salesforce and an update operation to Salesforce. I originally created this web service to only handle outbound messages and I created it using Salesforce's instructions.
I then needed to be able to use the same web service to update salesforce data. I created a new web method to accomplish this according to this set of Salesforce instructions.
My web service looks something like this:
namespace MySalesForce
{
[WebService(Namespace = "https://mynamespace.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class MySalesForceListener : INotificationBinding
{
public MySalesForceListener()
{
//Do some lovely initialization
}
[WebMethod]
public notificationsResponse notifications(notifications notifications)
{
//Do some stuff
}
[WebMethod]
public bool UpdateSalesForceData(Opportunity op)
{
//Do some updating
}
}
}
If I run my web service while passing an Opportunity parameter in the second method I get the following error:
Types 'MySalesForceListener.sforce.Opportunity' and 'Opportunity' both use the XML type name, 'Opportunity', from namespace 'urn:sobject.enterprise.soap.sforce.com'. Use XML attributes to specify a unique XML name and/or namespace for the type.
I understand why the error is happening. Opportunity is defined in the WSDL for outbound messages and the one for the Salesforce API and they both use the same Namespace definition:
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:sobject.enterprise.soap.sforce.com")]
public partial class Opportunity : sObject{...
What I don't know is how to properly address this issue. I'm hesitant to make changes to the generated NotificationServiceInterface.cs file(generated from outbound message WSDL) or the generated Reference.cs file generated from the API WSDL because said changes would be lost if the WSDL is updated and re-imported.
One thing I tried was passing a bunch of parameters to the UpdateSalesForceData method instead of an object but that is messy and I really do have a need to pass in an Opportunity object.
Any suggestions? Is there a correct way to implement a web service that handles updates to Salesforce and Outbound messages?