Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: How do I send a VFP Object to the Web Service?

$
0
0
Re: How do I send a VFP Object to the Web Service?
Web Service Proxy Generator
Re: How do I send a VFP Object to the Web Service?
Jul. 26, 2013
07:46 am
3UA0GNZA5Show this entire thread in new window
Gratar Image based on email address
From:Dean Phillips
To:Dean Phillips
Rick,

Here is a sample SOAPUI Project they sent me. It looks like there is a context labeled credentials. Does that confirm that I should use the SOAP Header route or am I way off? Unfortunately, the folks on the other end of this are clueless. I also tried to to follow your suggestion but I get an error on the SetPropertyEx call for "index was outside the bounds of the array". I checked previous posts for that error and I'm pretty sure I'm running the latest version.

*** Load Proxy Class and DependenciesDO BatchFilesServiceProxy*** Create Proxy Instance & specify .NET versionLOCAL loService as BatchFilesServiceProxy loService = CREATEOBJECT("BatchFilesServiceProxy","V2") loBridge = loService.oBridge loBridge.LoadAssembly('c:\BatchFilesServiceProxy.dll') loUser = loBridge.CreateInstance("BatchFilesService.Credentials")*o.SetPropertyEx(loInstance,lcProperty,loValue) loBridge.SetPropertyEx(loService,"Credentials.Username","galileotest") loBridge.SetPropertyEx(loService,"Credentials.Password","Webpass2") loBridge.SetPropertyEx(loService,"Credentials.Submitter","INTERN")*** Call your methods and retrieve result lxResult = loService.RetrieveAvailableFiles(loValue)*** Check for error message if result is failingIF !EMPTY(loService.cErrorMsg)MESSAGEBOX(loService.cErrorMsg,16,'ERROR')ENDIF


- <con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="CreateSubmitBatch TestCase" searchProperties="true"><con:settings /> - <con:testSteptype="request" name="CreateSubmitBatch"><con:settings /> - <con:config xsi:type="con:RequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:interface>BatchFilesBinding</con:interface><con:operation>LocalAccum Send - CreateSubmitBatch</con:operation> - <con:requestname="CreateSubmitBatch"> - <con:settings><con:settingid="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>https://services.relayhealth.com/AtsWebServices/pub/Batch</con:endpoint> - <con:request> - <![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bat="http://batch.v1.atsws.relayhealth.com/"><soapenv:Header/><soapenv:Body><bat:CreateSubmitBatchRequest/></soapenv:Body></soapenv:Envelope>]]></con:request> - <con:credentials><con:username>testuser2</con:username><con:password>Webpass1</con:password></con:credentials><con:jmsConfig JMSDeliveryMode="PERSISTENT" /><con:jmsPropertyConfig /><con:wsaConfigaction="http://batch.v1.atsws.relayhealth.com/BatchFiles/CreateSubmitBatchRequest" mustUnderstand="NONE" version="200508" /><con:wsrmConfigversion="1.2" /></con:request></con:config></con:testStep><con:properties /></con:testCase>


I'm using the WSDL generator to access a Web Service but I'm having trouble passing the User Credential object from VFP to the WebService. I tried adding the credentials to the header and even with HTTPLogin commands but no luck. The admin of the WebService gave me an example in C# but that doesn't really help me since I'm unfamiliar with C# (its at the bottom).

Reflector info:
For some reason the image didnt come through. I can email it if necessary.

*** Load Proxy Class and DependenciesDO BatchFilesServiceProxy*** Create Proxy Instance & specify .NET versionLOCAL loService as BatchFilesServiceProxy loService = CREATEOBJECT("BatchFilesServiceProxy","V2") loBridge = loService.oBridge loBridge.LoadAssembly('c:\BatchFilesServiceProxy.dll') loUser = GetUserCredentials() loUser.UserID = "galileotest" loUser.Password = "Webpass2" loUser.SubmitterID = "INTERN"*!* ** Create Custom HTTP Headers for Authorization *!* loService.oService.AddHttpHeader("UserID","galileotest") *!* loService.oService.AddHttpHeader("Password","Webpass2") *!* loService.oService.AddHttpHeader("SubmitterID","INTERN") *** Try to login --- this functions but doesn't authenticate with the Web Service llLogin = loService.HttpLogin("galileotest","Webpass2",.T.)*** Create a COM Value structureLOCAL loValue as BatchFilesService.RetrieveAvailableFilesRequest.ComValue loValue = loBridge.CreateComValue()*** Invoke a method and set the value from the method result loValue.SetValueFromInvokeMethod(loService.oService,"RetrieveAvailableFilesRequest",loUser)*** Call your methods and retrieve result lxResult = loService.RetrieveAvailableFiles(loValue)*** Check for error message if result is failingIF !EMPTY(loService.cErrorMsg)MESSAGEBOX(loService.cErrorMsg,16,'ERROR')ENDIF*******************************************FUNCTION GetUserCredentialsLOCAL loUser loUser = CREATEOBJECT("EMPTY")ADDPROPERTY(loUser,"UserID","")ADDPROPERTY(loUser,"Password","")ADDPROPERTY(loUser,"SubmitterID","")RETURN loUserENDFUNC


Here is the excerpts from the admin's example that uses a form to call the RetrieveAvailableFiles function by sending the User Credentials object.

publicpartialclass myForm : Form {public myForm () { InitializeComponent (); } UserCredentials user = new UserCredentials () { UserID = "galileotest", Password = "Webpass1", SubmitterID = "INTERN", };privatevoid btnSubmit_Click ( object sender, EventArgs e ) { SubmitBatchFilesToServer ( user ); } privatevoid btnListAvFiles_Click ( object sender, EventArgs e ) { RetrieveReports (user); }publicvoid RetrieveReports ( UserCredentials user ) {//proxy BatchFilesClient batchclient = new BatchFilesClient (); batchclient.ClientCredentials.UserName.UserName = user.UserID; batchclient.ClientCredentials.UserName.Password = user.Password; BatchFiles client = batchclient.ChannelFactory.CreateChannel ();//request RetrieveAvailableFilesRequest1 req = new RetrieveAvailableFilesRequest1 (); req.RetrieveAvailableFilesRequest = new RetrieveAvailableFilesRequest ();//response RetrieveAvailableFilesResponse1 resp = client.RetrieveAvailableFiles ( req ); txtGetFiles.Text = resp.RetrieveAvailableFilesResponse.@return.response;


Viewing all articles
Browse latest Browse all 10393

Latest Images

Trending Articles



Latest Images