0

私はWebサービス/API呼び出しにかなり慣れていません

私は開発用の wsdl を与えられました。

http://bogus.com/SM/7/ServiceCatalogAPI.wsdl

Visual Studio 2010 c# .net 4.0 を使用して wsdl へのサービス参照を追加しました

ユーザー名/パスワードが与えられました (基本認証)

リクエストの方法についてのガイダンスを探しています。私は正しい道を進んでいますか?

私は次のものを持っていますが、「型 'string' を 'SM9.ServiceReference1.StringType' に暗黙的に変換できません」というメッセージが表示されます

protected void Button1_Click(object sender, EventArgs e)
{
    try
    {
        ServiceReference1.CreateCartRequest createCart = new ServiceReference1.CreateCartRequest();

        string result = createCart.model.instance.BriefDescription = "Testing SM9";

        Label1.Text = result.ToString();
    }
    catch (System.Exception ex)
    {
        Label1.Text = ex.Message;
    }
}

SOAP リクエスト

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:ns="http://schemas.hp.com/SM/7" xmlns:cmn="http://schemas.hp.com/SM/7/Common">
  <soap:Body>
    <ns:CreateCartRequest>
      <ns:model>
        <ns:keys/>
        <ns:instance>
          <ns:BriefDescription type="">Brief Description</ns:BriefDescription>
          <ns:Description type="">
            <ns:Description type="">description 1</ns:Description>
            <ns:Description type="">description 2</ns:Description>
          </ns:Description>
        </ns:instance>
      </ns:model>
    </ns:CreateCartRequest>
  </soap:Body>
</soap:Envelope>

SOAP レスポンス

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Body>
    <CreateCartResponse message="Success" returnCode="0" schemaRevisionDate="2012-09-12" schemaRevisionLevel="0" status="SUCCESS" xmlns="http://schemas.hp.com/SM/7" xmlns:cmn="http://schemas.hp.com/SM/7/Common" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.hp.com/SM/7 http://SE104636.devfg.RBC.com:12700/SM/7/Cart.xsd">
      <model>
        <keys>
          <CartID type="Decimal">11</CartID>
        </keys>
        <instance recordid="11" uniquequery="cartId=11">
          <CartID type="Decimal">11</CartID>
          <Completed type="Boolean">false</Completed>
          <BriefDescription type="String">Brief Description</BriefDescription>
          <Owner type="String">SOAP USER</Owner>
          <Description type="Array">
            <Description type="String">description 1</Description>
            <Description type="String">description 2</Description>
          </Description>
          <Cost type="Decimal">0</Cost>
        </instance>
      </model>
      <messages>
        <cmn:message>svcCart record added.</cmn:message>
      </messages>
    </CreateCartResponse>
  </SOAP-ENV:Body>
4

1 に答える 1

0

BriefDescriptionは文字列型ではないようです。次のようなことを試してください:

string result = createCart.model.instance.BriefDescription = new StringType("Testing SM9");

また

 string result = createCart.model.instance.BriefDescription = new StringType() { Value = "Testing SM9" };

(申し訳ありませんが、「StringType」が実際に持っているプロパティはわかりません)。

于 2013-05-14T04:09:32.613 に答える