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)]
    // 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

    public notificationsResponse notifications(notifications notifications)
        //Do some stuff          

    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:

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?

2 Answers 2


When I've done it in the past I've created a batch file that takes the outbound message WSDL that Salesforce provides and creates the corresponding service interface.

As part of that batch file I pass a parameters to wsdl.exe to set the specific namespace it will be generated with.

E.g. (line breaks added for clarity)

wsdl /language:CS 
     /serverInterface SalesforceOutbound.wsdl

This is repeatable and will give you a separate namespace for the generated SOAP proxy classes.

I'd also separate your web method out into a different web service if possible. Leave this one to solely focus on handling the outbound messages that Salesforce is sending. It will make it easier if the ops people want to lock it down to only talk to Salesforce IP addresses.

  • Is it necessary to change the namespace per your suggestion if I break this into two web services?
    – Bruno
    Apr 29, 2015 at 16:10
  • @Bruno I'd probably still split the namespaces to avoid confusion. It will be clearer which WSDL you are working with based on the namespace. If you later add additional outbound messages those can go in different namespaces as well. Apr 29, 2015 at 19:28
  • Ah ok that makes sense and will definitely help because I'm pretty sure I'll have to handle multiple outbound messages soon. Thanks!
    – Bruno
    Apr 29, 2015 at 19:30

You can try using Salesforce Partner.WSDL (not Enterprise.WSDL). Being loosely coupled, Partner API allows you to define your types in run-time and shoult not be conflicting with namespace.

Refer:- https://www.salesforce.com/developer/docs/api/Content/calls_and_the_partner_wsdl.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .