function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ManishDhuparManishDhupar 

URGENT: New Error while making a Login call using C#

We are trying to integrate one of our Commerce Application with our Salesforce Instance and during the login call we receive the following error using C#/.NET.  However the login works through  console application however but throws the error through the .dll (compiled with the same code) which is called by our Commerce Application.

 

A few days back we recieved the below error

 

Exception : System.Web.Services.Protocols.SoapHeaderException: Required field/property SforceService.LoginScopeHeaderValue of SOAP header LoginScopeHeader was not set by the client prior to making the call.
at System.Web.Services.Protocols.SoapHeaderHandling.GetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client)
at System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize(WebRequest request, String methodName, Object[] parameters)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Mercury_SFAdapter.Sforce.SforceService.login(String username, String password)
at Mercury_SFAdapter.Mercury_SFAdapterSvc.login()

 

which got resolved by declaring the LoginScopeHeader as below.

 

binding.LoginScopeHeaderValue = new Mercury_SFAdapter.Sforce.LoginScopeHeader();

 

Thanks to some quick help from SimonF

 

http://community.salesforce.com/sforce/board/message?board.id=NET_development&message.id=5675&jump=true#M5675

 

Yesterday  we created a new field in ourSandbox Instance and downloaded and updated the new .wsdl file.

(Sandbox now showing Spring 08)

 

We started recieving the below exception message for AssignmentRuleHeader

 

ERROR: System.Web.Services.Protocols.SoapHeaderException: Required field/property SforceService.AssignmentRuleHeaderValue of SOAP header AssignmentRuleHeader was not set by the client prior to making the call.

   at System.Web.Services.Protocols.SoapHeaderHandling.GetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client)

   at System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize(WebRequest request, String methodName, Object[] parameters)

   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

 

On creating a AssignmentRuleHeaderValue insatance as done above for LoginScopeHeaderValue

 

leads to message for DebuggingHeaderValue , EmailHeaderValue ,MruHeaderValue and so on.

 

private bool login()

{

binding = new Mercury_SFAdapter.Sforce.SforceService();

try

{

//execute the login placing the results

//in a LoginResult object

binding.LoginScopeHeaderValue = new Mercury_SFAdapter.Sforce.LoginScopeHeader();

Mercury_SFAdapter.Sforce.LoginResult loginResult = binding.login("username", "password");

if (!loginResult.passwordExpired)

{

binding.Url = loginResult.serverUrl;

//set the session id header for subsequent calls

binding.SessionHeaderValue = new Mercury_SFAdapter.Sforce.SessionHeader();

binding.SessionHeaderValue.sessionId = loginResult.sessionId;

return true;

}

else

{

QLogWrapper.m_staticLogger.logComment("Password is Expired");

}

}

catch (Exception ex)

{

QLogWrapper.m_staticLogger.logComment("Exception : " + ex);

}

//Login failed, report message then return false

//--------Console.WriteLine("Login failed with message: " + ex.Message);

return false;

}


 


 

Request some immediate assistance on this.

 

Thank you,

Manish K Dhupar


 

SuperfellSuperfell
Never seen this problem before what exact version of .NET are you using, and are you using the regular tools (wsdl.exe, add web reference), or WCF?
ManishDhuparManishDhupar

Hello Simon,

We are using .Net 1.1 and are using the inbuilt tool "Add web Referance" from .NET

Thanks

manish

 

ManishDhuparManishDhupar
Hello Simon,
Does SF support .Net 2002.
Do you think the issue could be due to this?
 
Any quick/help assistance is highly appreciated.
 
Do you have a number where you can be contacted.
 
Thank you,
 
Regards.
Manish
 
ManishDhuparManishDhupar

We have narrowed down the problem.

To be more precise the exact error/exception occurs during the below Create Account call.

 

Mercury_SFAdapter.Sforce.SaveResult[] saveResults = binding.create(records);

 

We receive SOAP header exceptions:

 

1.   ERROR: System.Web.Services.Protocols.SoapHeaderException: Required field/property SforceService.AssignmentRuleHeaderValue of SOAP header AssignmentRuleHeader was not set by the client prior to making the call.   at System.Web.Services.Protocols.SoapHeaderHandling.GetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client)   at System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize(WebRequest request, String methodName, Object[] parameters)   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

 

Action:

When we define the SOAP Header value (AssignmentRuleHeaderValue) as below then we receive next exception

 

binding.AssignmentRuleHeaderValue = new Mercury_SFAdapter.Sforce.AssignmentRuleHeader();

 

binding.AssignmentRuleHeaderValue.useDefaultRule=true;

 

2. ERROR: System.Web.Services.Protocols.SoapHeaderException: Required field/property SforceService.EmailHeaderValue of SOAP header EmailHeader was not set by the client prior to making the call.   at System.Web.Services.Protocols.SoapHeaderHandling.GetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client)   at System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize(WebRequest request, String methodName, Object[] parameters)   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

 

Action:

 

binding.EmailHeaderValue = new Mercury_SFAdapter.Sforce.EmailHeader();

 

3. On making above changes we get similar SOAPHeaderExceptions for MruHeaderValue, UserTerritoryDeleteHeaderValue, LocaleOptionsValue and DebuggingInfoValue(Please see below exception)

 

4. ERROR: System.Web.Services.Protocols.SoapHeaderException: Client did not find required DebuggingInfo SOAP header in the message.   at System.Web.Services.Protocols.SoapHeaderHandling.SetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client)   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream)   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

 

 

Finally, we are stuck at this exception even after setting the header value as shown below.

 

binding.DebuggingInfoValue = new Mercury_SFAdapter.Sforce.DebuggingInfo();

 

Kindly suggest what all SOAPHeaderValues need to be set and let us know if any other setting/values are required to be done in Salesforce UI to get rid of these exception.

 

We are using Create and Update calls for Accounts, Contacts and one Custom object (Serial number).

 

Please Note that the same code works fine through a console application but throws these exceptions when a .dll (using similar code) is called through our commerce application

 

Some URGENT assistance would be highly appreciated.

 

Thank you,

Manish

 

 

 

 

SuperfellSuperfell
I'd start them by looking at what your commerce system sets up differently, it appears that its adding something to the .NET config to enforce additional rules the .NET engine doesn't normally enforce, and that's what's causing the problems.
ManishDhuparManishDhupar
Hello Simon,
 
Could you suggest where can we verify these settings and what are the suggested values for SOAP headers.
 
Our commerce system is being used to fetch Account related information, prepares a Recordset and passes on to the fucntion which Creates an account in SF.
 
We use the same code to create
1. Console Application (.exe which works fine)
2. and a .dll where the problem occurs.
 
Is there some difference in how SF handles request from a .dll and .exe
 
error occurs during a create Account Call
 

Mercury_SFAdapter.Sforce.SaveResult[] saveResults = binding.create(records);

 

Regards,

Manish

 

SuperfellSuperfell
This is nothing to do with the API, and is to do with the .NET Soap stack in your application. (you can confirm with a soap diagnostics tool that these errors are not being generated by the salesforce.com servers).