忍者ブログ
開発中に遭遇した落とし穴や忘れそうな事柄を書いた個人メモ
カレンダー
03 2024/04 05
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
フリーエリア
最新コメント
[02/03 NONAME]
最新トラックバック
プロフィール
HN:
No Name Ninja
性別:
非公開
バーコード
ブログ内検索
アクセス解析
28
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

web.configに追記

<configuration>
 <system.web>
  <globalization culture="ja-jp" uiCulture="ja-jp" />
 </system.web>
</configuration>

これで、日時や通貨など、日本語にそくしたレイアウトで出力される

拍手

Azureにおいて、日時に取り扱いは注意が必要
現在日時を求めるときDateTime.Nowで取得すると、UTC基準の日時で取得される
そのため、時差の補正を行う必要がある。

これを回避するために、現在日時を特定の場所(たとえば、日本など)のタイムゾーンで保管しておくと
補正の必要がなくなる(ただし、ワールドワイドにサイトを展開する場合は、その限りでない)

そこで、DateTime.Nowで取得しているところを

TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now.ToUniversalTime(), "Tokyo Standard Time");

に変更する。

懸案事項
まだ、よくわかっていないが、ストレージに保管されたテーブルの内容を確認すると
(VS2010のサーバーエクプローラーで)、上記の方法で、日時を保管すると
現在日時+9時間で保管されている?????
ただし、これでGridViewで内容を表示するとちゃんと現在日時として表示できている

DateTime.Nowで保管すると、ストレージの内容は、現在日時になっているが、
GridViewで表示すると、-9時間された日時が出力される?????

なんで、このような動作になってしまうか、現時点不明


もうひとつ、わからないところは、Timestampのフィールドは、-9時間されてストレージに保管されていて
GridViewにこのまま出力すると、-9時間された内容そのままで出力される?????
上記のパターンでいけば、-18時間されて出力されていいはずがそうならない!!なぜか不明

まあ、どっか勘違いしていると思われるが。。。。。。。

拍手

最後に、クライアント側の構成ファイルを説明

構成ファイルを作成するにあたっては、VisualStudio2010の
「サービス参照の追加」を利用して作成するとある程度ひな形が作成できる
(svcutilで作成されるものと同じもの)

サービス参照の追加ダイアログを開き
アドレスを入力
http://xxx.co.jp:80/Service/Service1.svc
 

移動ボタンをクリックすると
サービスの内容がしたに表示される
OKボタンで、ソースが生成される

この時、構成ファイルも追加される(赤字)
一部、設定を追加する(青字)
ClientBehaviorの定義によって、とりあえずルート証明がない証明書も許可しておく


    <system.serviceModel>
      <bindings>
        <wsHttpBinding>
          <binding name="WSHttpBinding_ITraceLogService" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
            textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
            <security mode="Message">
              <transport clientCredentialType="Windows" proxyCredentialType="None"
                realm="" />
              <message clientCredentialType="None" negotiateServiceCredential="true"
                algorithmSuite="Default" />
            </security>
          </binding>
        </wsHttpBinding>
      </bindings>
      <behaviors>
        <endpointBehaviors>
          <behavior name="ClientBehavior">
            <clientCredentials>
              <serviceCertificate>
                <authentication certificateValidationMode="PeerOrChainTrust" />
              </serviceCertificate>
            </clientCredentials>
          </behavior>
        </endpointBehaviors>
      </behaviors>
      <client>
        <endpoint address="http://xxx.co.jp/Service/Service1.svc"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITraceLogService"
          contract="MainService.ITraceLogService" name="WSHttpBinding_ITraceLogService" behaviorConfiguration="ClientBehavior">
          <identity>
            IDが生成される一部省略
            <certificate encodedValue="AwAAAAEAAAAUAAAAnvfi4F7J  ----------  " />
          </identity>
        </endpoint>
      </client>
    </system.serviceModel>

拍手

次に、サーバー側のロールの構成ファイル(configファイル)を修正する。
今回、WEBロールのweb.configファイルが対象となる

WEBサービスは、System.ServiceModelで定義される
1.bindingsにwsHttpBindingの情報を定義する(赤字で記載)
     今回、認証は行わないため、clientCredentialType="None"になる

2.behaviorsを定義する(緑字で記載)
  MyBehaviorの<serviceCredentials>内容が重要
      先ほど登録した、サーバー認証用の証明書を検索する条件が定義されている
  省略しているが、SroreName="My"
      あと検索にあたっては、x509FindType="FindBySubjectName"により、
  この場合、サブジェクトで、findValueの内容を検索している

3.上記の内容をserviceに関連付ける(青字で記載)

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="MyBinding">
          <security>
            <message clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="MyBehavior" name="WebRole.Service.Service1">
        <!-- サービスのEndpoint定義-->
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyBinding" contract="WebRole.Service.IService1" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
        <behavior name="MyBehavior">
          <serviceCredentials>
            <serviceCertificate findValue="xxx.co.jp" x509FindType="FindBySubjectName" />
          </serviceCredentials>
          <serviceDebug />
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

 

拍手

Copyright c 技術メモ All Rights Reserved
Powered by ニンジャブログ  Designed by ピンキー・ローン・ピッグ
忍者ブログ / [PR]