1

I am using a SAP web service and I am using BCS to get the external data. However, when I try to create a new item via code I get this error:

Stack trace:

The remote server returned an error: (500) Internal Server Error.
at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataConnection.ThrowBCSException(WebException webException) at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataConnection.ExecuteRequest(IBCSODataRequest requestMsg) at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataDirectConnection.ExecuteRequest(IBCSODataRequest requestMsg) at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataConnection.ExecuteODataServiceRequest(String odataUrl, String httpMethod, String mimeType, IDictionary`2 requestHeaders, Boolean encodeRequest, IList`1 inputValues) at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataServiceProxy.ExecuteInternal(String httpMethod, String mimeType, ODataConnection odataConnection, IMethodInstance methodInstance, IParameterCollection methodInputParameters, Object[] methodInputArgs, IParameter parameterWithDirectionReturn, PayloadKind payloadType, Boolean setupParameters, Boolean encodeRequest) at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataServiceProxy.InvokeODataService(ODataConnection odataConnection, IMethodInstance methodInstance, IParameterCollection methodInputParameters, Object[] methodInputArgs, IParameter parameterWithDirectionReturn) at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataServiceProxy.Execute(IMethodInstance methodInstance, IParameterCollection methodInputParameters, Object[] methodInputArgs, IParameter parameterWithDirectionReturn) at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataSystemUtility.ExecuteInternal(IMethodInstance methodInstance, Object[]& methodSignatureArgs) at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataSystemUtility.Execute(Object[] args) at Microsoft.SharePoint.BusinessData.SystemSpecific.OData.ODataSystemUtility.ExecuteStatic(IMethodInstance methodInstance, ILobSystemInstance lobSystemInstance, Object[] args, IExecutionContext context) at Microsoft.SharePoint.BusinessData.Runtime.DataClassRuntime.ExecuteInternalWithAuthNFailureRetry(ISystemUtility systemUtility, IMethodInstance methodInstanceToExecute, IMethod methodToExecute, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IParameterCollection nonReturnParameters, Object[] overrideArgs) at Microsoft.SharePoint.BusinessData.Runtime.DataClassRuntime.ExecuteInternal(IDataClass thisDataClass, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IMethodInstance methodInstanceToExecute, IMethod methodToExecute, IParameterCollection nonReturnParameters, Object[]& overrideArgs) at Microsoft.SharePoint.BusinessData.Runtime.EntityRuntime.ExecuteInternal(IDataClass thisDataClass, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IMethodInstance methodInstanceToExecute, IMethod methodToExecute, IParameterCollection nonReturnParameters, Object[]& overrideArgs, IFilterCollection filters) at Microsoft.SharePoint.BusinessData.Runtime.EntityRuntime.Create(IEntity thisEntity, IFieldValueDictionary fieldValues, Identity identity, AssociationEntityInstancesDictionary associationInfo, ILobSystemInstance lobSystemInstance) at Microsoft.SharePoint.BusinessData.MetadataModel.Static.Entity.Create(IFieldValueDictionary fieldValues, ILobSystemInstance lsi) at VisualWebPartProject1.CreateDossier.CreateDossier.Button1_Click(Object sender, EventArgs e)

Here is my code:

using (new SPServiceContextScope(SPServiceContext.GetContext(SPContext.Current.Site)))
                {
                    // Get the BDC service and metadata catalog.
                    BdcService service = SPFarm.Local.Services.GetValue<BdcService>(String.Empty);
                    IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);

                    // Get the entity using the specified name and namespace.
                    IEntity entity = catalog.GetEntity("NSpace", "EntName");
                    ILobSystemInstance lobSysteminstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value;

                    // Get the fields on the entity.
                    IView createView = entity.GetCreatorView("CreateItem");
                    IFieldValueDictionary valueDictionary = createView.GetDefaultValues();


                    // Set the values of the entity fields.
                    //valueDictionary["CustomerId"] = Convert.ToString(myRandomNumber);
                    valueDictionary["fiw_zztype_de_dmnd"] = "";
                    valueDictionary["fiw_zzdoss_type"] = "";
                    valueDictionary["fiw_zzsimpl_doss"] = "";
                    valueDictionary["fiw_p"] = "";
                    valueDictionary["fiw_g"] = "";
                    valueDictionary["fiw_e"] = "";
                    valueDictionary["fiw_uname"] = "";
                    valueDictionary["fiw_language"] = "";

                   entity.Create(valueDictionary, lobSysteminstance);
                }

1 Answer 1

1

please check the webservice is running, secondly make sure that the webservice is pointing to the correct location (the wsdl url location is correct)!

its failing on bsc ExecuteRequest with a 500 internal service error indicating a url missmatch (pointing to wrong location) using http instead of https or wrong proxy settings / credentials!

the error doesnt really show much to determin where exactly its comming from! you need to debug the code within the exectue to find out where its failing!

did you get the error from uls log or eventviewer? when you run the code does the page display the 500 error?

have you tried turing on tracing on iis to see the error?

http://www.iis.net/ConfigReference/system.webServer/tracing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.