My PayPal Direct script works perfect on my machine. Both nUnit tests and via a website on localhost. However this first line of code fails on my server and another server. (both full trust)
CallerServices caller = new CallerServices();
Message: The type initializer for 'com.paypal.sdk.core.soap.SOAPAPICaller' threw an exception.
Source: paypal_base
Stack Trace:
at com.paypal.sdk.core.soap.SOAPAPICaller..ctor()
at com.paypal.sdk.services.CallerServices..ctor()
at TS.Common.BusinessLogic.PaymentGateways.PayPalProController.CChargeCard(String paymentAmount, Order CurrentOrder, String creditCardType, String creditCardNumber, String CVV2, String expMonth, String expYear, PaymentActionCodeType paymentAction, Transaction& transaction)
at TS.Common.BusinessLogic.PaymentGateways.PayPalProController.ChargeCard(Order CurrentOrder, Decimal Amount, String CreditCardNum, String ExpMonth, String ExpYear, String SecurityNumber, Transaction& transaction)
at OrderController.SubmitCreditCardPayment(Order order, Decimal ChargeAmount, String CreditCardNum, String ExpMonth, String ExpYear, String Var, String CardType, Transaction& transaction)
at OrderController.SubmitOrder(Order order, Transaction& transaction, Nullable`1 GiftCertId, String CreditCardNum, String ExpMonth, String ExpYear, String Var, String CardType, String Culture)
at Checkout.btnOrder_Click(Object sender, EventArgs e) in d:\Inetpub\tickets\Checkout.aspx.cs:line 488
Add log4net.dll , if not put it in your bin folder and add reference. It works for me...
Add the reference to the log4net.dll with the specific version only. It will work
Related
I have created a wrapper class to create an Object and send it as a request to a third party system. It was working well. But after I added a two new arguments of the Datatype Date, I am getting the below error.
Constructor not defined: [SFDC_DataObject.CustomerAccountObject].<Constructor>(Id, String, Id, String, Id, String, Integer, NULL, String, String, Id, String, NULL, String, String, String, String)
The request that I am creating and sending is as below.
SFDC_DataObject.CustomerAccountObject cusAccObj = new SFDC_DataObject.CustomerAccountObject(o.AccountId, o.Customer_Name__c, o.Agency_Name__r.Id,o.Agency_Name_OB__c, o.Opportunity.OwnerId, o.Opportunity.Owner.FederationIdentifier, PrimarySalesSplitPercent, null, secSOSalesforceId.get(o.OpportunityId), secSOSalesforceEmail.get(o.OpportunityId), o.Opportunity.Customer_Success_Manage__r.Id, o.Opportunity.Customer_Success_Manage__r.FederationIdentifier, null, o.Billing_Email__c, o.Billing_Phone__c, o.Bill_To_Name__c, o.Billing_Notes__c);
My wrapper class for the same object is as below.
public class CustomerAccountObject {
public String sfCustomerId;
public String customerName;
public String sfAgencyId;
public String agencyName;
public String sfPrimarySalesOwnerId;
public String primarySalesOwnerEmail;
public Integer primarySalesOwnerPercentage;
public Date primarySalesOwnerEffectiveFrom;
public String sfSecondarySalesOwnerId;
public String secondarySalesOwnerEmail;
public Date secondarySalesOwnerEffectiveFrom;
public String sfAccountManagerId;
public String accountManagerEmail;
public String billingEmail;
public String billingPhone;
public String billingName;
public String billingNotes;
public CustomerAccountObject() {}
public CustomerAccountObject(String sfCustomerId, String customerName, String sfAgencyId, String agencyName, String sfPrimarySalesOwnerId, String primarySalesOwnerEmail, Integer primarySalesOwnerPercentage, Date primarySalesOwnerEffectiveFrom, String sfSecondarySalesOwnerId, String secondarySalesOwnerEmail, Date secondarySalesOwnerEffectiveFrom, String sfAccountManagerId, String accountManagerEmail, String billingEmail, String billingPhone, String billingName, String billingNotes) {
this.sfCustomerId = sfCustomerId;
this.customerName = customerName;
this.sfAgencyId = sfAgencyId;
this.agencyName = agencyName;
this.sfPrimarySalesOwnerId = sfPrimarySalesOwnerId;
this.primarySalesOwnerEmail = primarySalesOwnerEmail;
this.primarySalesOwnerPercentage = primarySalesOwnerPercentage;
this.primarySalesOwnerEffectiveFrom = primarySalesOwnerEffectiveFrom;
this.sfSecondarySalesOwnerId = sfSecondarySalesOwnerId;
this.secondarySalesOwnerEmail = secondarySalesOwnerEmail;
this.secondarySalesOwnerEffectiveFrom = secondarySalesOwnerEffectiveFrom;
this.sfAccountManagerId = sfAccountManagerId;
this.accountManagerEmail = accountManagerEmail;
this.billingEmail = billingEmail;
this.billingPhone = billingPhone;
this.billingName = billingName;
this.billingNotes = billingNotes;
}
}
I began getting the error after I added the null for the Date arguments I.e primarySalesOwnerEffectiveFrom and secondarySalesOwnerEffectiveFrom during the Object creation.
Can anyone please let me know what am I doing wrong here.
The order is wrong.
In c-tor definition you have
String sfCustomerId, String customerName, String sfAgencyId, String
agencyName, String sfPrimarySalesOwnerId, String
primarySalesOwnerEmail, Integer primarySalesOwnerPercentage, Date
primarySalesOwnerEffectiveFrom, String sfSecondarySalesOwnerId, String
secondarySalesOwnerEmail, Date secondarySalesOwnerEffectiveFrom + 6 more Strings
So
... Integer, Date, String, String, Date, ...
But the code that calls it goes
o.AccountId, o.Customer_Name__c,
o.Agency_Name__r.Id,o.Agency_Name_OB__c, o.Opportunity.OwnerId,
o.Opportunity.Owner.FederationIdentifier, PrimarySalesSplitPercent,
null, secSOSalesforceId.get(o.OpportunityId),
secSOSalesforceEmail.get(o.OpportunityId),
o.Opportunity.Customer_Success_Manage__r.Id,
o.Opportunity.Customer_Success_Manage__r.FederationIdentifier, null, +
4 strings
There are extra 2 strings before 2nd null. And only 4 strings after it. You need to inject that null just after secSOSalesforceEmail?
This will get only worse to maintain as time goes on. Consider making a simple constructor and making the properties public. You could then set them after constructor in normal call. And if you don't need dates you just don't write line that sets date fields instead of injecting null at right position.
Follow-up edit
Not sure if there's an official guide to that technique or a blog post. Tools like Apex-PMD complain when you make methods with too many arguments, rules like "Avoid long parameter lists".
One way would be to do something like this:
SFDC_DataObject.CustomerAccountObject cusAccObj = new SFDC_DataObject.CustomerAccountObject();
cusAccObj.sfCustomerId = o.AccountId;
cusAccObj.customerName = o.Customer_Name__c;
cusAccObj.sfAgencyId = o.Agency_Name__c;
cusAccObj.agencyName = o.Agency_Name_OB__c;
cusAccObj.sfPrimarySalesOwnerId = o.Opportunity.OwnerId;
cusAccObj.primarySalesOwnerEmail = o.Opportunity.Owner?.FederationIdentifier;
cusAccObj.primarySalesOwnerPercentage = PrimarySalesSplitPercent;
// cusAccObj.primarySalesOwnerEffectiveFrom = null; // just don't bother with the line?
cusAccObj.sfSecondarySalesOwnerId = secSOSalesforceId.get(o.OpportunityId);
// ..
That's not very object oriented, not very elegant but caller has full control on the mapping. Problem will be if you need to map new field and this has been copy-pasted into 10 places. You'll have to update them all (which will be easier than adding N-th parameter to long call but still)
Another way would be to create a baseline constructor that takes whole Order object (it's an Order, right?), it'd map the fields internally. Then if needed - you specify some extra fields after constructor. Or maybe make few constructors?
public CustomerAccountObject(){
// I'm parameterless, I'm doing nothing! I'm just here if somebody needs a really custom field mapping or JSON deserialisations need a parameterless one
}
public CustomerAccountObject(Order o){
// I can map all fields from Order! Want to map new field? Just chuck it in here!
sfCustomerId = o.AccountId;
// ...
}
public CustomerAccountObject(Order o, Map<Id, String> secSOSalesforceId, Map<Id, String> secSOSalesforceEmail){
// I can do everything above and few more fields too!
this(o);
sfSecondarySalesOwnerId = secSOSalesforceId.get(o.OpportunityId);
secondarySalesOwnerEmail = secSOSalesforceEmail.get(o.OpportunityId);
}
You have bit of code reuse, the Order fields mapping is defined in just 1 place, just 1 line to change in future. You don't have an orgy of this everywhere anymore. And then your call if you really need the last constructor or you'll call the one that just takes Order o and then set the 2 extra fields after it finishes.
Is there a way for me to send an array in Restful Web Services?
I am currently using : #Produces(MediaType.TEXT_PLAIN)
When I tried to use below code, I always get Null Pointer Exception for the methodClass value.
public int adaptiveAuth( #FormDataParam("uuid") String uuID,
#FormDataParam("browserinfo") String browserInfo,
#FormDataParam("ipint") long ipInt,
#FormDataParam("lat") double latiTude,
#FormDataParam("longitude") double longiTude,
#FormDataParam("sessionid") String sessionID,
#FormDataParam("spid") String spID,
#FormDataParam("tr") int tR,
#FormDataParam("jsnum") int jsNum,
#FormDataParam("fingerprint") String fingerPrint ,
#FormDataParam("methodset") MethodClass[][] methodSet) throws SQLException{
Is there any other way for me to send/receive MethodClass[][] in Restful Web Service?
Sample data for MedthodClass[1][1]
Thank you.
From the following stacktrace, I can't tell what is wrong by the error message. I ran the migration command with --verbose flag hoping it would help pinpoint the issue but zilch.
dotnet ef migrations add migwl3 --verbose
I can't find a parameter named key
System.ArgumentNullException: Value cannot be null.
Parameter name: key
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName)
at Microsoft.EntityFrameworkCore.SqlServerMetadataExtensions.SqlServer(IKey key)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer. <Add>d__41.MoveNext()
at System.Linq.Enumerable.<CastIterator>d__35`1.MoveNext()
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer. <Add>d__29.MoveNext()
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer. <DiffCollection>d__56`1.MoveNext()
at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.S ort(IEnumerable`1 operations, DiffContext diffContext)
at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.Scaf foldMigration(String migrationName, String rootNamespace, String subNamespace)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMig ration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(S tring name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Exec ute(Action action)
Value cannot be null.
Parameter name: key
Any tips on how to zero in on the issue (the project compiles fine) would be greatly appreciated
This is one of the first results from searching for Microsoft.EntityFrameworkCore.Utilities.Check.NotNull, so I'll add my stupid mistake:
I refactored a class to a different DatabaseContext, and was then calling Join between two IQueryable queries from those different contexts-- Obviously you can't do that in EntityFramework
I think Your Problem is Your Model that you not decoration [Key] attribute Or
Not use HasKey.
please share your code.
make sure that you wrote the Interface name in the constructor not the repository name.
example program
private IReviewRepository _reviewRepository;
private IPokemonRepository _pokemonRepository;
private readonly IReviewerRepository _reviewerRepository;
private IMapper _mapper;
public ReviewController(IReviewRepository reviewRepository,
IMapper mapper,
IPokemonRepository pokemonRepository,
IReviewerRepository reviewerRepository)
{
_reviewRepository = reviewRepository;
_pokemonRepository = pokemonRepository;
_reviewerRepository = reviewerRepository;
_mapper = mapper;
}
ReviewRepository instead of IReviewRepository
ReviewerRepository instead of IReviewerRepository
PokemonRepository instead of IPokemonRepository
I have API like this-
/objectname/name
/objectname/collection/id
Both API's are indirectly related.
Problem occurs when calling first API with name value as "A/B Type". So rest controller actually calling second API rather first (/objectname/A/B Type) because forward slash. How to deal with this situation.
As a side note I am encoding the parameters values.
I developed the restful services using SpringBoot and RestTemplate.
The conflict comes by specifying the name directly in the resource path and passed to the function as a #PathVariable.
Your code looks something like this:
#RequestMapping(value = "objectname/{name}", method = RequestMethod.GET)
public String yourMethodName(#PathVariable String name){
return name;
}
What I would recommend in order to avoid this kind of conflict is (if you're allowed to modify the #RestController or #RepositoryRestResource layers) to pass the value of the object in a #RequestParam
For instance:
#RequestMapping(value = "/objectname", method = RequestMethod.GET)
public String yourMethodName(#RequestParam(name = "name", required = true) String name){
return name;
}
That said, When you are constructing your the request using RestTemplate then you should url encode your name (A%2FB%20Testing) and construct the following url:
http://localhost:8080/objectname?name=A%2FB%20Testing
I tested this locally and worked alright for me.
I've test the db connection without Websecurity and it works. I've followed the tutorial from Brice Lambson http://brice-lambson.blogspot.com.es/2012/10/entity-framework-on-postgresql.html
But when I use
WebSecurity.InitializeDatabaseConnection("myContext",
"UserProfile", "UserId", "UserName", autoCreateTables: false);
I get this exception:
System.InvalidOperationException was caught
HResult=-2146233079
Message=No user table found that has the name "UserProfile".
Source=WebMatrix.WebData
StackTrace:
in WebMatrix.WebData.SimpleMembershipProvider.ValidateUserTable()
in WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider simpleMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables)
in WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables)
in WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables)
in Glink.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() en c:\Users\...\InitializeSimpleMembershipAttribute.cs:line 46
InnerException: Npgsql.NpgsqlException
HResult=-2147467259
Message=ERROR: 42601: Syntax error near «[»
Source=Npgsql
ErrorCode=-2147467259
BaseMessage=Syntax error near «[»
Code=42601
Detail=""
ErrorSql=SELECT [UserId] FROM [UserProfile] WHERE (UPPER([UserName]) = ((E'Z')))
File=src\backend\parser\scan.l
Hint=""
Line=1002
Position=8
Routine=scanner_yyerror
Severity=ERROR
Where=""
StackTrace:
in Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext()
in Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()
in Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
in Npgsql.ForwardsOnlyDataReader.NextResult()
in Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError)
in Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)
in Npgsql.NpgsqlCommand.ExecuteScalar()
in WebMatrix.Data.Database.QueryValue(String commandText, Object[] args)
in WebMatrix.WebData.DatabaseWrapper.QueryValue(String commandText, Object[] parameters)
in WebMatrix.WebData.SimpleMembershipProvider.GetUserId(IDatabase db, String userTableName, String userNameColumn, String userIdColumn, String userName)
in WebMatrix.WebData.SimpleMembershipProvider.ValidateUserTable()
InnerException:
I guess that NpgSql could not be prepared to work with SimpleMerbership, but I'd like to know if any of you had tried this.
Thank you!!
You should try Daniel Nauck's AspSQLProvider: http://dev.nauck-it.de/projects/show/aspsqlprovider
It is a PostgreSQL implementation of the ASP.NET 2.0+ Membership, Role, Profile and Session-State Store Provider.
I hope it helps.
I'd hint you to try changing "autoCreateTables: false" to "autoCreateTables: true".
Doesn't work with postgres because it injects brackets ([ ... ]) into throughout the embedded SQL:
https://github.com/aspnetwebstack/aspnetwebstack/blob/master/src/WebMatrix.WebData/SimpleMembershipProvider.cs