Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

Invoke Web Service

I've been supplied by a vendor with url that when I go to it has a simple input box
I have test xml that I simply paste into that box
Click Invoke
And XML response is returned

I need example C# or VB code of how to accomplish that from a web form server side code.
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

It depends if the form the vendor gave you supports parameters. If it doesn't then there is nothing you can do.  If it does, then let me know which parameter it is expecting.
Avatar of Larry Brister

ASKER

This url times out.
Randy...
That's not the actual domain
If I go to the url and invoke without any content I get this

<?xml version="1.0" encoding="UTF-8"?>
<string xmlns="http://www.DOMAINREDACTED.com/"><?xml version="1.0" encoding="utf-8" ?><ChargeResponse xmlns="http://www.DOMAINREDACTED.com/"><Result>Error</Result><CompanyId></CompanyId><CustomerId></CustomerId><LoanNumber></LoanNumber><ReferenceNo></ReferenceNo><ApprovalCode></ApprovalCode><MsgDescription>Modify header error: Invalid xml request format. </MsgDescription><RequestTime></RequestTime><ResponseTime></ResponseTime></ChargeResponse></string>
so it is expecting you to send it the parameters as an XML or SOAP request.  If going to the url doesn't tell you what it is expecting, then you will need to get that information from the people who created the site.
Quite often they can be exposed by navigating your browser to:
https://approvals.theirdomain.com/webservices/Wspaymentprocess/paymentprocess.asmx

and remove the op to get a list of functions and what they expect.
Wait...
If I go to their url
And simply drop in the XML and invoke
That doesn't indicate its a XML Post?
no it doesn't
Avatar of kaufmed
You need to find out what kind of service this is. Is it SOAP or REST? The kind of service will dictate how you call it from code.
I am using this...
            using (var client = new raMakePaymentDev.PaymentProcessSoapClient("PaymentProcessSoap1"))
            {
                string s = client.CreditRequest(GetTextFromXMLFile(Server.MapPath("XMLFile.xml"))).ToString();
            }

Open in new window


And getting this exact (password etc changed for this post) response back...
<?xml version="1.0" encoding="utf-8" ?><ChargeResponse xmlns="http://www.ramembers.com/"><Result>Error</Result><CompanyId></CompanyId><CustomerId></CustomerId><LoanNumber></LoanNumber><ReferenceNo></ReferenceNo><ApprovalCode></ApprovalCode><MsgDescription>Modify header error: Invalid xml request format. <?xml version="1.0" encoding="utf-8"?>
<ChargeRequest xmlns="http://www.ramembers.com/">
  <UserName>sdptobwphbnpohp[</UserName>
  <Password>sdpoifuhvpsediubvhsbwphbp</Password>
  <CompanyId>TU</CompanyId>
  <CustomerId>00171</CustomerId>
  <PaymentType>141</PaymentType>
  <CreditCardNumber>4111111111111111</CreditCardNumber>
  <CVV2>325</CVV2>
  <ExpirationMonth>07</ExpirationMonth>
  <ExpirationYear>2020</ExpirationYear>
  <Amount>2.00</Amount>
  <CurrencyType>840</CurrencyType>
  <FirstName>Billy</FirstName>
  <MiddleName></MiddleName>
  <LastName>Bates</LastName>
  <HolderAddress>99999 SW 25TH Street</HolderAddress>
  <HolderCity>Miami</HolderCity>
  <HolderState>Florida</HolderState>
  <HolderZipCode>33067</HolderZipCode>
  <HolderCountry>USA</HolderCountry>
  <Comments></Comments>
  <UserCode>meterCode</UserCode>
  <PointofSale>WEB</PointofSale>
</ChargeRequest></MsgDescription><RequestTime></RequestTime><ResponseTime></ResponseTime></ChargeResponse>

Open in new window

Ok... is a soap service.
It looks like you've already got the code that will call the service. so what is the issue? The parameter list of CreditRequest should tell you what to pass.
In thread ID: 41548930
If I take that same exact XML that it is showing has error...
And go directly to the Web Service URL...
And paste it in and invoke
It works and returns an "Approved" message

I cannot "get" why this is failing code side.
What is the method signature of client.CreditRequest?
kaufmed...
I recognized the vowels and consonants of your question.
How do I determine that?
What are the parameters (and their types) and what is the return type?
Kaufmed...
I truly am missing your question since I have limited background in this from the technical side

If the url is...(actual domain changed)
https://approvals.theirdomain.com/webservices/Wspaymentprocess/paymentprocess.asmx?op=ChargeRequestIntegration

And the XML is
<ChargeRequest xmlns="http://www.ramembers.com/">
  <UserName>sdptobwphbnpohp[</UserName>
  <Password>sdpoifuhvpsediubvhsbwphbp</Password>
  <CompanyId>TU</CompanyId>
  <CustomerId>00171</CustomerId>
  <PaymentType>141</PaymentType>
  <CreditCardNumber>4111111111111111</CreditCardNumber>
  <CVV2>325</CVV2>
  <ExpirationMonth>07</ExpirationMonth>
  <ExpirationYear>2020</ExpirationYear>
  <Amount>2.00</Amount>
  <CurrencyType>840</CurrencyType>
  <FirstName>Billy</FirstName>
  <MiddleName></MiddleName>
  <LastName>Bates</LastName>
  <HolderAddress>99999 SW 25TH Street</HolderAddress>
  <HolderCity>Miami</HolderCity>
  <HolderState>Florida</HolderState>
  <HolderZipCode>33067</HolderZipCode>
  <HolderCountry>USA</HolderCountry>
  <Comments></Comments>
  <UserCode>meterCode</UserCode>
  <PointofSale>WEB</PointofSale>
</ChargeRequest>

What do you mean by Paramaters?
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Kaufmed...
This is what I get with hover
string PaymentProcessSoapClient.CreditRequest(string creditrequest1)
You put me on the right track.

Turns out they had a typo in their documentation and it was actually another method.

When I did mouse-over and sent them screen print they "remembered" the changed code.