I am using ASP.NET and C# to display a form for someone to complete and submit a request to an external company on a button click. The company provided a WSDL file which i was able to import into my Solution as a Web Reference. Once I added the reference it generated a bunch of classes which appears to create an XML file and from what I understand is what I need to do. I given an example of what an XML file submittion looks like but I am a little confused on how to the web reference and submit the request.
Here is the WSDL
I am trying call the complextype (method) ClaimSubmittalRequest This is what I was able to do in my C# code (get and set the fields):
var submitClaim = new ThermalKing.SubmitClaimRequest
{
claimLanguage = "ENG",
serviceVersion = "1.0",
claimType = "PARTS",
failureDate = new DateTime(2014, 11, 26),
faultFound = "PERFORM A FREE INSPECTION"
};
var submitParts = new ThermalKing.eachPart
{
partNumber = "1234",
partPrice = 100.78,
partQuantity = 17
};
Here is what the example XML File looks like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:get="http://data-test.thermoking.com/ThermoKingWebServices/SubmitClaim/getSubmitClaimWSD">
<soapenv:Header/>
<soapenv:Body>
<get:getSubmitClaim>
<SubmitClaimRequest>
<buName>Thermo King TSA</buName>
<dealerNumber>P5358</dealerNumber>
<userName></userName>
<password></password>
<transactionType>WARRANTY</transactionType>
<claimType>Machine</claimType>
<inventorySerialNumber>6001061225</inventorySerialNumber>
<repairDate>2011-09-05T00:00:00.000-05:00</repairDate>
<failureDate>2011-09-05T00:00:00.000-05:00</failureDate>
<workOrderNumber>testProcede1</workOrderNumber>
<conditionsFound>test</conditionsFound>
<workPerformed>test</workPerformed>
<claimNotes>test claim notes</claimNotes>
<!-- will be optional fields in the future -->
<faultLocation>FF</faultLocation>
<faultFound>BLOWN/BURST</faultFound>
<failureDetail xsi:nil="true"/>
<smrClaim>N</smrClaim>
<forceToDraft>Y</forceToDraft>
<validateOnly>N</validateOnly>
<commercialPolicy>N</commercialPolicy>
<!-- will be optional fields in the future -->
<fuelSurcharge>0</fuelSurcharge>
<shopSupplies>0</shopSupplies>
<claimCurrency>USD</claimCurrency>
<workOrderSegment>1</workOrderSegment>
<claimLanguage>ENG</claimLanguage>
<serviceVersion>1.0</serviceVersion>
<partsType>
<!--1 or more repetitions:-->
<eachPart>
<partType>IRREMOVED</partType>
<partNumber>416780</partNumber>
<partQuantity>1.0</partQuantity>
<partPrice>1.23</partPrice>
<partDescription>test part desc</partDescription>
</eachPart>
<eachPart>
<partType>NONIR</partType>
<partNumber>1</partNumber>
<partQuantity>1.0</partQuantity>
<partPrice>1</partPrice>
<partDescription>test non IR</partDescription>
</eachPart>
<eachPart>
<partType>IRINSTALLED</partType>
<partNumber>416780</partNumber>
<partQuantity>1.0</partQuantity>
<partPrice>1</partPrice>
<partDescription>test ir installed</partDescription>
</eachPart>
</partsType>
<jobCodesType>
<!--1 or more repetitions:-->
<eachJobCode>
<jobCode>05051</jobCode>
<standardLaborHours>1</standardLaborHours>
<additionalLaborHours>.5</additionalLaborHours>
<laborRate>92.22</laborRate>
<ReasonForAdditionalLaborHours>test</ReasonForAdditionalLaborHours>
</eachJobCode>
</jobCodesType>
<usageMetersType>
<!--1 or more repetitions:-->
<eachUsageMeter>
<usageAmount>1661</usageAmount>
<usageType>HoursInService</usageType>
<usageUOM>HOURS</usageUOM>
</eachUsageMeter>
</usageMetersType>
</SubmitClaimRequest>
</get:getSubmitClaim>
</soapenv:Body>
</soapenv:Envelope>
How can I call the Complex Type Method in my C# code to send the request to the external company? Or is it easier just to create an XML file manually using C#?
UPDATED CODE:
using (var client = new getSubmitClaimWSD_PortTypeClient())
{
SubmitClaimRequest request = new SubmitClaimRequest()
{
buName = "Thermo King TSA",
dealerNumber = "PHSDF",
userName = "Roger",
password = "1234",
transactionType = "WARRANTY",
claimLanguage = "ENG",
serviceVersion = "1.0",
claimType = "PARTS",
failureDate = new DateTime(2014, 11, 26),
faultFound = "PERFORM A FREE INSPECTION",
inventorySerialNumber = "12352341",
repairDate = new DateTime(2014, 11, 26),
workOrderNumber = "testProcede1",
conditionsFound = "test",
workPerformed = "test",
claimNotes = "test claim notes",
faultLocation = "FF",
failureDetail = "test",
smrClaim = "N",
forceToDraft = "Y",
validateOnly = "N",
commercialPolicy = "N",
fuelSurcharge = 0,
shopSupplies = 0,
claimCurrency = "USD",
workOrderSegment = "1",
partsType = new[]
{
new eachPart() {partNumber = "1234", partPrice = 100.78, partQuantity = 17, partType = "NONIR", partDescription = "test part desc"},
new eachPart() {partNumber = "5678", partPrice = 200.90, partQuantity = 1, partType = "IRREMOVED", partDescription = "test part desc 2"}
}
};
var response = client.getSubmitClaim(null, request);
var rsp = response.response;
Console.WriteLine("Status {0}, claim {1}; {2} {3}, {4} errors", rsp.status, rsp.claimNumber,
rsp.workOrderNumber, rsp.workOrderSegment, rsp.errorsType.Length);
}
usingblocks is the service. One is the request, and the other is part of the request.