开发者

Consuming Soap service, receiving as object, how to write as XML?

I am a junior developer, and trying to write an application to consume SOAP web service.

Using web reference, I can easily call web method of Soap web server, but the problem is that the server return an object (UBL XML object I think). And I can access its individual elements/nodes as a XML object. But if I want output its response to a XML file/object, how could I do it? It's probably a trivial task to output the object as a XML object, but I am not sure where to start. I've tried that simple call ToString() of the returned object wouldn't work. Do I need went a level down passing http POST sent SOAP header and body and interpreting/writing response stream to get response as XML text?

This is the code I used to retrieve UBL formated XML object:

/// <summary>
/// Used by supplier to check Order
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnRequestPO_Click(object sender, EventArgs e)
{
    string t_return;
    SupplierServices supplierServices = new SupplierServices();

    LoginDetails lgDetails = new LoginDetails();
    lgDetails.UserName = "user";
    lgDetails.Password = "password";
    supplierServices.LoginDetailsValue = lgDetails;

    RequestPurchaseOrder requestPO = new RequestPurchaseOrder();
    requestPO.SupplierCode = "1234";
    try
    {
        Order returned_order = supplierServices.SupplierRequestPO(requestPO);
        if (returned_order != null)
        {
            //Simply call the ToString wouldn't work, it will return a
            //class name instead.
            t_return = returned_order.ToString();
            MessageBox.Show(t_return);
        }
        else
            MessageBox.Show("Returned order is empty!");
    }
    catch (Exception ex)
    {
        String responseFromServer = ex.Message.ToString() + " ";
        if (ex!= null)
        {
          MessageBox.Show(responseFromServer);
        }
    }  

And here is the SOAP response I should get:

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SupplierRequestPOResponse xmlns="https://extranet.thewarehouse.co.nz/ElectronicCommerce/">
      <Order xmlns="urn:oasis:names:specification:ubl:schema:xsd:Order-2">
        <ID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        <CopyIndicator xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        <IssueDate xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        <Note xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        <Note xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        <DocumentCurrencyCode xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        <CustomerReference xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        <LineCountNumeric xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        <ValidityPeriod xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <StartDate xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <EndDate xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <Description xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <Description xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        </ValidityPeriod>
        <ValidityPeriod xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <StartDate xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <EndDate xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <Description xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <Description xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        </ValidityPeriod>
        <BuyerCustomerParty xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <CustomerAssignedAccountID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <Party>
            <EndpointID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartyName xsi:nil="true" />
            <PartyName xsi:nil="true" />
            <PostalAddress xsi:nil="true" />
            <PhysicalLocation xsi:nil="true" />
            <PartyTaxScheme xsi:nil="true" />
            <PartyTaxScheme xsi:nil="true" />
          </Party>
          <BuyerContact>
            <ID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Name xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Telephone xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Telefax xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          </BuyerContact>
        </BuyerCustomerParty>
        <SellerSupplierParty xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <CustomerAssignedAccountID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <Party>
            <EndpointID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartyName xsi:nil="true" />
            <PartyName xsi:nil="true" />
            <PostalAddress xsi:nil="true" />
            <PhysicalLocation xsi:nil="true" />
            <PartyTaxScheme xsi:nil="true" />
            <PartyTaxScheme xsi:nil="true" />
          </Party>
        </SellerSupplierParty>
        <ManufacturerParty xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <EndpointID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <PartyName>
            <Name xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          </PartyName>
          <PartyName>
            <Name xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          </PartyName>
          <PostalAddress>
            <StreetName xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <AdditionalStreetName xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <CitySubdivisionName xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <CityName xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Country xsi:nil="true" />
          </PostalAddress>
          <PhysicalLocation>
            <Address xsi:nil="true" />
          </PhysicalLocation>
          <PartyTaxScheme>
            <RegistrationName xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <CompanyID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <TaxScheme xsi:nil="true" />
          </PartyTaxScheme>
          <PartyTaxScheme>
            <RegistrationName xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <CompanyID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <TaxScheme xsi:nil="true" />
          </PartyTaxScheme>
        </ManufacturerParty>
        <Delivery xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <Quantity xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <TrackingID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <DeliveryParty>
            <EndpointID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartyName xsi:nil="true" />
            <PartyName xsi:nil="true" />
            <PostalAddress xsi:nil="true" />
            <PhysicalLocation xsi:nil="true" />
            <PartyTaxScheme xsi:nil="true" />
            <PartyTaxScheme xsi:nil="true" />
          </DeliveryParty>
        </Delivery>
        <Delivery xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <Quantity xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <TrackingID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <DeliveryParty>
            <EndpointID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartyName xsi:nil="true" />
            <PartyName xsi:nil="true" />
            <PostalAddress xsi:nil="true" />
            <PhysicalLocation xsi:nil="true" />
            <PartyTaxScheme xsi:nil="true" />
            <PartyTaxScheme xsi:nil="true" />
          </DeliveryParty>
        </Delivery>
        <TransactionConditions xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <ID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <ActionCode xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <Description xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <Description xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <DocumentReference>
            <ID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <CopyIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <UUID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <IssueDate xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <DocumentTypeCode xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <DocumentType xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <XPath xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <XPath xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Attachment xsi:nil="true" />
          </DocumentReference>
          <DocumentReference>
            <ID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <CopyIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <UUID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <IssueDate xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <DocumentTypeCode xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <DocumentType xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <XPath xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <XPath xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Attachment xsi:nil="true" />
          </DocumentReference>
        </TransactionConditions>
        <TaxTotal xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <TaxAmount xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        </TaxTotal>
        <TaxTotal xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <TaxAmount xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        </TaxTotal>
        <AnticipatedMonetaryTotal xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <LineExtensionAmount xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <AllowanceTotalAmount xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <PayableAmount xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
        </AnticipatedMonetaryTotal>
        <OrderLine xmlns="urn:oasis:n开发者_高级运维ames:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <Note xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <LineItem>
            <ID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Note xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineStatusCode xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Quantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineExtensionAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <TotalTaxAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MinimumQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MaximumBackorderQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartialDeliveryIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <BackOrderAllowedIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Delivery xsi:nil="true" />
            <Delivery xsi:nil="true" />
            <PricingReference xsi:nil="true" />
            <Price xsi:nil="true" />
            <Item xsi:nil="true" />
          </LineItem>
          <BuyerProposedSubstituteLineItem>
            <ID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Note xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineStatusCode xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Quantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineExtensionAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <TotalTaxAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MinimumQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MaximumBackorderQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartialDeliveryIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <BackOrderAllowedIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Delivery xsi:nil="true" />
            <Delivery xsi:nil="true" />
            <PricingReference xsi:nil="true" />
            <Price xsi:nil="true" />
            <Item xsi:nil="true" />
          </BuyerProposedSubstituteLineItem>
          <BuyerProposedSubstituteLineItem>
            <ID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Note xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineStatusCode xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Quantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineExtensionAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <TotalTaxAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MinimumQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MaximumBackorderQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartialDeliveryIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <BackOrderAllowedIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Delivery xsi:nil="true" />
            <Delivery xsi:nil="true" />
            <PricingReference xsi:nil="true" />
            <Price xsi:nil="true" />
            <Item xsi:nil="true" />
          </BuyerProposedSubstituteLineItem>
        </OrderLine>
        <OrderLine xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
          <Note xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
          <LineItem>
            <ID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Note xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineStatusCode xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Quantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineExtensionAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <TotalTaxAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MinimumQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MaximumBackorderQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartialDeliveryIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <BackOrderAllowedIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Delivery xsi:nil="true" />
            <Delivery xsi:nil="true" />
            <PricingReference xsi:nil="true" />
            <Price xsi:nil="true" />
            <Item xsi:nil="true" />
          </LineItem>
          <BuyerProposedSubstituteLineItem>
            <ID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Note xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineStatusCode xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Quantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineExtensionAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <TotalTaxAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MinimumQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MaximumBackorderQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartialDeliveryIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <BackOrderAllowedIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Delivery xsi:nil="true" />
            <Delivery xsi:nil="true" />
            <PricingReference xsi:nil="true" />
            <Price xsi:nil="true" />
            <Item xsi:nil="true" />
          </BuyerProposedSubstituteLineItem>
          <BuyerProposedSubstituteLineItem>
            <ID xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Note xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineStatusCode xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Quantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <LineExtensionAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <TotalTaxAmount xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MinimumQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <MaximumBackorderQuantity xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <PartialDeliveryIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <BackOrderAllowedIndicator xsi:nil="true" xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
            <Delivery xsi:nil="true" />
            <Delivery xsi:nil="true" />
            <PricingReference xsi:nil="true" />
            <Price xsi:nil="true" />
            <Item xsi:nil="true" />
          </BuyerProposedSubstituteLineItem>
        </OrderLine>
      </Order>
    </SupplierRequestPOResponse>
  </soap:Body>
</soap:Envelope>


You can use the XmlSerializer:

public static string Serialize(object input)
{
    if (input == null)
        return null;

    System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(input.GetType());

    using (MemoryStream ms = new MemoryStream())
    using (StreamReader sr = new StreamReader(ms))
    {
        ser.Serialize(ms, input);
        ms.Seek(0, 0);
        return sr.ReadToEnd();
    }
}

and pass your returned_order in like so:

MessageBox.Show(Serialize(returned_order));


Mark Avenius has provided a good example of how to convert any object to XML. If that's all that you are trying to do, his answer will suit your needs perfectly.

However, it sounds as if you are trying to verify the SOAP response itself - XmlSerializer will not allow you to do that. Instead, it is converting an object to its own idea of what that object should look like in XML, and not what you received over the wire.

If you are in fact trying to verify the SOAP response, I'd recommend using the wonderful tool Fiddler. It will allow you to hand-craft any type of web request, including SOAP, and to analyze the exact responses received. It is invaluable for .NET web development.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜