cancel
Showing results for 
Search instead for 
Did you mean: 

Object Reference not Set in CIM SOAP

I am having problems with the CreateCustomerPaymetProfile() function in the SOAP AIM, working in VB.Net.  I am getting an “Object reference not set” Error on the CustomerPaymentProfileType method. However no errors are showing up in Visual Web Developer code editor.

 

Before I run this I run the CreateCustomerProfile() function and that runs OK, no errors.

 

Below is the code I am trying. If I comment out all of the “new_payment_profile” lines I don’t get the error (“new_payment” and “new_card” are OK). Any help would be appreciated.

    Public Function CreateCustomerPaymentProfile(ByVal CPID As Long, ByVal Name As String, ByVal Address As String, ByVal City As String, ByVal Zip As String, ByVal CardNumber As String, ByVal ExpDate As String) As Long

        Dim new_payment_profile As New CIMService.CustomerPaymentProfileType()
        Dim new_payment As New CIMService.PaymentType()
        Dim new_card As New CIMService.CreditCardType()
        new_payment_profile.billTo.firstName = Name     
        new_payment_profile.billTo.address = Address	
        new_payment_profile.billTo.city = City		
        new_payment_profile.billTo.zip = Zip		
        new_card.cardNumber = CardNumber
        new_card.expirationDate = ExpDate
        new_payment.Item = new_card
        new_payment_profile.payment = new_payment
        Dim response As CIMService.CreateCustomerPaymentProfileResponseType = Service.CreateCustomerPaymentProfile(MerchantAuthentication, CPID, new_payment_profile, CIMService.ValidationModeEnum.liveMode)

        Dim out_id As Long = 0
        If Len(response.customerPaymentProfileId) > 0 Then
            out_id = response.customerPaymentProfileId
        Else
            For i As Integer = 0 To response.messages.Length - 1
                SessionClass.ErrorMsg += response.messages(i).text
            Next
        End If
        Return out_id
    End Function

 Thanks

 

rd5leng
Member
1 ACCEPTED SOLUTION

Accepted Solutions

Don't need the reference.vb. I was just wondering if it something wrong with the C# to VB translation.

 

I copy your code to my test project the error I got was on the

new_payment_profile.billTo.firstName = Name

 

so, I added just before that line

new_payment_profile.billTo = new CIMService.CustomerAddressType()

 

other than that it was ok.

View solution in original post

7 REPLIES 7

Did you copy and modify the web reference from the sample code or did your own? Can't see why it will false on that. Can you trace thru the code.

RaynorC1emen7
Expert

I mostly copied this from the C# sample code for CIM SOAP and ran it through an online translator to get  vb. and then pulled out the CreateCustomerProfile() and CreateCustomerPaymentProfile() functions along with the

Service(), MerchantAuthentication(), properties and the 3 Constants and 2 variables used by the properties

I added the WSDL file from here  (https://api.authorize.net/soap/v1/Service.asmx?WSDL)  named the folder CIMService and changed all the references in the CustomerProfile functions to match, I made no changes to the WSDL file. I also changed  the CustomerProfile functions from Public Shared to just Public as I was getting reference errors in the editor with the shared functions.

The CreateCustomerProfile function runs great and I can add live profiles to our CIM with it, so I really don't understand why the CreatCustomerPaymentProfile would throw this error, and I don't even know where to look, since the methods used within these functions are all created from the WSDL file. I went through the code commenting out lines and I believe the error is from the CustomerPaymentProfileType object named new_payment_profile. the other objects in the function do not seem to cause a problem

 

I enabled page trace and pasted the results below. Not sure what to look for in all of that either.

 

Thanks for the Help

 

 

aspx.pageBegin PreInit  
aspx.pageEnd PreInit1.36190493484507E-050.000014
aspx.pageBegin Init3.51301631911318E-050.000022
aspx.pageEnd Init5.15428636879827E-050.000016
aspx.pageBegin InitComplete6.32063572325533E-050.000012
aspx.pageEnd InitComplete7.48000094984139E-050.000012
aspx.pageBegin LoadState8.61841379281445E-050.000011
aspx.pageEnd LoadState0.0002144127256397110.000128
aspx.pageBegin ProcessPostData0.0002294286005623620.000015
aspx.pageEnd ProcessPostData0.0004137397350780620.000184
aspx.pageBegin PreLoad0.0004288254512794220.000015
aspx.pageEnd PreLoad0.0004406286273814130.000012
aspx.pageBegin Load0.0004517333906963040.000011
aspx.pageEnd Load0.0004642349795853940.000013
aspx.pageBegin ProcessPostData Second Try0.0004755492667364150.000011
aspx.pageEnd ProcessPostData Second Try0.0004866540300513050.000011
aspx.pageBegin Raise ChangedEvents0.0004975492695300660.000011
aspx.pageEnd Raise ChangedEvents0.0005179429229133870.000020
aspx.pageBegin Raise PostBackEvent0.0005312826071469980.000013
Unhandled Execution Error
Object reference not set to an instance of an object.
  at Payments.CreateCustomerPaymentProfile(Int64 CPID, String Name, String Address, String City, String Zip, String CardNumber, String ExpDate)
  at PmtSystemTest.RunTestButton2_Click(Object sender, EventArgs e)
  at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
  at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
  at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
0.003860965569646420.003330

Control TreeControl UniqueID Type Render Size Bytes (including children) ViewState Size Bytes (excluding children) ControlState Size Bytes (excluding children)

__PageASP.pmtsystemtest_aspx000
    ctl02System.Web.UI.LiteralControl000
    ctl00System.Web.UI.HtmlControls.HtmlHead000
        ctl01System.Web.UI.HtmlControls.HtmlTitle000
    ctl03System.Web.UI.LiteralControl000
    form1System.Web.UI.HtmlControls.HtmlForm000
        ctl04System.Web.UI.LiteralControl000
        RunTestBttonSystem.Web.UI.WebControls.Button000
        ctl05System.Web.UI.LiteralControl000
        TestResultsSystem.Web.UI.WebControls.Label000
        ctl06System.Web.UI.LiteralControl000
        CPIDSystem.Web.UI.WebControls.TextBox000
        ctl07System.Web.UI.LiteralControl000
        CardNumberSystem.Web.UI.WebControls.TextBox000
        ctl08System.Web.UI.LiteralControl000
        ExpDateSystem.Web.UI.WebControls.TextBox000
        ctl09System.Web.UI.LiteralControl000
        RunTestButton2System.Web.UI.WebControls.Button000
        ctl10System.Web.UI.LiteralControl000
        TestResults2System.Web.UI.WebControls.Label000
        ctl11System.Web.UI.LiteralControl000
        ErrorMsgSystem.Web.UI.WebControls.Label000
        ctl12System.Web.UI.LiteralControl000
    ctl13System.Web.UI.LiteralControl000

Session StateSession Key Type ValueApplication StateApplication Key Type ValueRequest Cookies CollectionName Value SizeResponse Cookies CollectionName Value SizeHeaders CollectionName Value

Connectionkeep-alive
Content-Length274
Content-Typeapplication/x-www-form-urlencoded
Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encodinggzip, deflate
Accept-Languageen-us,en;q=0.5
Hostmultihullnetsnew.multihullnets.com
Refererhttp://multihullnetsnew.multihullnets.com/PmtSystemTest.aspx
User-AgentMozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1

Response Headers CollectionName Value

X-AspNet-Version2.0.50727
Cache-Controlprivate
Content-Typetext/html

Form CollectionName Value

__VIEWSTATE/wEPDwUKLTU0ODc4NTc0MWRksGP49BDIixHKI0vB0aLtNoQW040=
__EVENTVALIDATION/wEWBgLN3py2BALWzrD7AgLK7ZrjAQKi0rDKCALhkra6AQKXs5LxDi9cgnXewVzGxY9+T2iTk3NjsTVC
CPID45198835
CardNumber4111111111111
ExpDate2015-03
RunTestButton2Run CreateCustomerPaymentProfile

Querystring CollectionName ValueServer VariablesName Value

ALL_HTTPHTTP_CONNECTION:keep-alive HTTP_CONTENT_LENGTH:274 HTTP_CONTENT_TYPE:application/x-www-form-urlencoded HTTP_ACCEPT:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:en-us,en;q=0.5 HTTP_HOST:multihullnetsnew.multihullnets.com HTTP_REFERER:http://multihullnetsnew.multihullnets.com/PmtSystemTest.aspx HTTP_USER_AGENT:Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1
ALL_RAWConnection: keep-alive Content-Length: 274 Content-Type: application/x-www-form-urlencoded Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-us,en;q=0.5 Host: multihullnetsnew.multihullnets.com Referer: http://multihullnetsnew.multihullnets.com/PmtSystemTest.aspx User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1
APPL_MD_PATH/LM/W3SVC/184/ROOT
APPL_PHYSICAL_PATHE:\HostingSpaces\LocalUser\RLeng\MultihullnetsNew.multihullnets.com\wwwroot\
AUTH_TYPE 
AUTH_USER 
AUTH_PASSWORD 
LOGON_USER 
REMOTE_USER 
CERT_COOKIE 
CERT_FLAGS 
CERT_ISSUER 
CERT_KEYSIZE 
CERT_SECRETKEYSIZE 
CERT_SERIALNUMBER 
CERT_SERVER_ISSUER 
CERT_SERVER_SUBJECT 
CERT_SUBJECT 
CONTENT_LENGTH274
CONTENT_TYPEapplication/x-www-form-urlencoded
GATEWAY_INTERFACECGI/1.1
HTTPSoff
HTTPS_KEYSIZE 
HTTPS_SECRETKEYSIZE 
HTTPS_SERVER_ISSUER 
HTTPS_SERVER_SUBJECT 
INSTANCE_ID184
INSTANCE_META_PATH/LM/W3SVC/184
LOCAL_ADDR66.199.128.250
PATH_INFO/PmtSystemTest.aspx
PATH_TRANSLATEDE:\HostingSpaces\LocalUser\RLeng\MultihullnetsNew.multihullnets.com\wwwroot\PmtSystemTest.aspx
QUERY_STRING 
REMOTE_ADDR67.78.212.182
REMOTE_HOST67.78.212.182
REMOTE_PORT3613
REQUEST_METHODPOST
SCRIPT_NAME/PmtSystemTest.aspx
SERVER_NAMEmultihullnetsnew.multihullnets.com
SERVER_PORT80
SERVER_PORT_SECURE0
SERVER_PROTOCOLHTTP/1.1
SERVER_SOFTWAREMicrosoft-IIS/7.0
URL/PmtSystemTest.aspx
HTTP_CONNECTIONkeep-alive
HTTP_CONTENT_LENGTH274
HTTP_CONTENT_TYPEapplication/x-www-form-urlencoded
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_ENCODINGgzip, deflate
HTTP_ACCEPT_LANGUAGEen-us,en;q=0.5
HTTP_HOSTmultihullnetsnew.multihullnets.com
HTTP_REFERERhttp://multihullnetsnew.multihullnets.com/PmtSystemTest.aspx
HTTP_USER_AGENTMozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1

 

I created a new web site and did a "add web reference" to the apitest.authorize.net/soap/v1/service.asmx

And it works fine.

 

under your CIMService folder, does it have a reference.vb? if it exist, it probably something in the CustomerPaymentProfileType or CustomerPaymentProfileBaseType class.

No. my Web Reference folder only contains a Service.discomap and Service.wsdl files.

I noticed the C# sample contains a Reference.cs file but how would i get a Reference.vb file. I am using VisualWebDeveloper 2010 Express. I right click on the Solution Explorer, select Add Web Reference, enter the URL and click add. I have tried this several times and no reference file shows up.

Don't need the reference.vb. I was just wondering if it something wrong with the C# to VB translation.

 

I copy your code to my test project the error I got was on the

new_payment_profile.billTo.firstName = Name

 

so, I added just before that line

new_payment_profile.billTo = new CIMService.CustomerAddressType()

 

other than that it was ok.

That was it. Thanks.

Make sure Authorize.NET dll was not properly refresh in bin folder when creating a new Customer Profile on Authorize.NET.

 

I am using asp.net c# code.

 

So please refresh or remove and add new Authorize.NET dll and u will create new customer easily.