Jump to content

Need Help Converting C# Code Snippet to a PhP Function Called OpenWebService()


tedrico

Recommended Posts

I'd like to convert this C# Console Application to a Web Based Php Function Script Capable of Receiving a Pre-generated XML Code String:

 

<xs:schema xmlns="https://www.fastraxonline.com/SearchRequests.xsd" xmlns:mstns="https://www.fastraxonline.com/SearchRequests.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="SearchRequests" elementFormDefault="qualified">

<xs:element name="FastraxNetwork">
<xs:complexType>
<xs:sequence>
<xs:element name="search-criteria" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:choice>
<xs:element name="request-id" maxOccurs="1" minOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
<xs:minLength value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

 

This function must retain it's C@ based Web Service Consumption Ability. I am so stumped after 2 days of online converters and Github converters. All failed. Here is the C# Code:

 

using System;

using System.Xml;

namespace Sms.Demos.FastraxSelectSample
{
class Program
{
static void Main(string[] args)
{
//Use your Customer Location and password for Credentials.
string customerLocation = "abcd222#97531";
string password = "a1a1a1a1";
//Create an instance of the web service.
ConsoleApplication1.FastraxNetwork.FastraxNetworkSoapClient fn = new ConsoleApplication1.FastraxNetwork.FastraxNetworkSoapClient();
//Get login instance.
Console.WriteLine("Getting login information.");
ConsoleApplication1.FastraxNetwork.FastraxLogin login = fn.Login(customerLocation, password);

//Create the request.
string requestXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<FastraxRequests>
<request>
<subject-info>
<first-name>John</first-name>
<last-name>Doe</last-name>
<dob>1970-10-15</dob>
<ssn>999-99-9999</ssn>
<sex>M</sex>
<address-info>
<address>
<street-number>1</street-number>
<street-name>Main</street-name>
<street-type>Str</street-type>
<city>Cincinnati</city>
<state>OH</state>
<zip>45202</zip>
</address>
<phone-info>
<phones>
<phone-number>(513) 555-1234</phone-number>
<phone-type>Cell</phone-type>
</phones>
</phone-info>
</address-info>
<maiden-name>Deer</maiden-name>
</subject-info>
<report-info>
<individual-report ind-report-id=""24"">
<searchamerica />
</individual-report>
</report-info>
<client-field>
<id>Any info you want</id>
<our-trans>Echoed back to you in the report response</our-trans>
</client-field>
</request>

</FastraxRequests>"
;
//New Request - look at the returned Xml doc to get information about the
//request, the key is the RequestID.
Console.WriteLine("Send request and get response.");
string responseXml = fn.InsertRequests(login, requestXml);
Console.WriteLine("Parse response for request id.");
XmlDocument xmlResponse = new XmlDocument();
xmlResponse.LoadXml(responseXml);
string requestId = xmlResponse.DocumentElement
.SelectSingleNode(@"/FastraxNetwork/request/@request-id").Value;
Console.WriteLine("Request Id is " + requestId);
//For this example, allow the real time report time to process.
Console.WriteLine("Sleeping 5 seconds.");
System.Threading.Thread.Sleep(5000);
//Format an Xml document, use a Request ID to search and retrieve results
//of the Request
string xmlString = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<FastraxNetwork><search-criteria><request-id>"

+ requestId + "</request-id></search-criteria></FastraxNetwork>";
Console.WriteLine("Requesting results.");
string resultsXml = fn.RetrieveResults(login, xmlString);
Console.WriteLine("Displaying results.");
Console.WriteLine(resultsXml);
Console.ReadLine();
}
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.