2016-10-10 10 views
1

私は古いIIS 6サーバーでホストする必要があるWCFサービスを持っています。サーバーにはServer1という名前が付いていますが、Webサイトには別名も使用されています。どうやら、サーバーとウェブサイトは異なるIPアドレスを解決します。WSDLでのschemaLocationの変更

だから、WCFサービスパスが

https://alias.sys.domain.com/ProjectName/MyService.svc?wsdl

あるしかし、私はXMLが生成さを見たとき、schemaLocationはとして表示:

<wsdl:types> 
    <xsd:schema targetNamespace="http://tempuri.org/Imports"> 
    <xsd:import schemaLocation="https://server1.subdomain.domain.com/ProjectName/MyService.svc?xsd=xsd0" namespace="http://tempuri.org/" /> 
    <xsd:import schemaLocation="https://server1.subdomain.domain.com/ProjectName/MyService.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/ProjectName" /> 
    <xsd:import schemaLocation="https://server1.subdomain.domain.com/ProjectName/MyService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> 
    </xsd:schema> 
</wsdl:types> 

私はXMLで指定されたスキーマにアクセスしようとした場合

https://server1.subdomain.domain.com/ProjectName/MyService.svc?xsd=xsd0

「ページを表示できません」というエラーが表示され、Chromeのデバッグツールで[ネットワーク]タブを使用するとs、それはコールが中止されたことを示します。私は

https://alias.sys.domain.com/ProjectName/MyService.svc?xsd=xsd0

でスキーマにアクセスしようとした場合でも、その後、私は問題なくそれを得ることができますが、残念ながらこれはサービスで使用されるものではありません。

<serviceMetadata httpGetEnabled="true" httpsGetUrl="https://alias.sys.domain.com/ProjectName/MyService.svc" /> 

エラーの原因となった:私は.svc/mexを追加することで取り除くことができました

A registration already exists for URI

を、私は私の設定ファイルにhttpsGetURLを追加したことを変更するには

。奇妙なことは、無効な匿名認証のために使用できないので、mexエンドポイントがないことです。

しかし、追加/mex

<endpoint address="web1" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/> 

<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/> 

からそれを変える、

The message with To ' https://alias.sys.domain.com/ProjectName/MyService.svc/mex?wsdl ' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.

だから、私は自分のエンドポイントにアドレスを追加した別のエラーの原因となったと

を使用してみました

The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None) [/code]

に私のエラーを変え

https://alias.sys.domain.com/ProjectName/MyService.svc/web1

は誰でも助けることはできますか?

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding name="basicHTTP"> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Windows"> 
     </transport> 
     </security> 
    </binding> 
    </basicHttpBinding> 
    <webHttpBinding> 
    <binding name="webBinding"> 
     <security mode="Transport"> 
     <transport clientCredentialType="Windows"> 
     </transport> 
     </security> 
    </binding> 
    </webHttpBinding> 
</bindings> 
<services> 
    <service behaviorConfiguration="basicBehavior" name="ProjectName.MyService"> 
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/> 
    <!--<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />--> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="basicBehavior"> 
     <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
     <serviceCredentials> 
      <windowsAuthentication includeWindowsGroups="true" allowAnonymousLogons="false"> 
     </windowsAuthentication> 
    </serviceCredentials>--> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"/> 
</system.serviceModel> 

、ここインターフェースです:

public interface IMyService 
{ 

    [OperationContract] 
    [WebInvoke(UriTemplate = "GetStatus/{groupID}/{groupName}", Method = "GET", 
     ResponseFormat = WebMessageFormat.Json, 
     RequestFormat = WebMessageFormat.Json, 
     BodyStyle = WebMessageBodyStyle.WrappedRequest)] 
    string GetStatus(string groupID, string groupName); 

} 
+0

<services> <service behaviorConfiguration="basicBehavior" name="ProjectName.MyService"> <endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="basicBehavior"> <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> 

を変更することで問題を解決しましたか –

+0

web.configセクションとインターフェイスを追加しました。本当に助けていただきありがとうございます! – ElenaDBA

答えて

1

は、サービス・インターフェースおよびコンフィギュレーションファイル(エンドポイントタグ)を共有できますか?

<services> 
    <service behaviorConfiguration="basicBehavior" name="ProjectName.MyService"> 
    <endpoint address="https://alias.sys.domain.com/ProjectName/MyService.svc" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/> 

    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="basicBehavior"> 
     <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" httpsGetUrl="https://alias.sys.domain.com/ProjectName/MyService.svc/ssl"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 

    </behavior> 
    </serviceBehaviors> 
</behaviors> 
1

あなたは、WSDLを使ってRESTfulなサービス操作を消費することはできません。メタデータは?wsdlクエリで公開されていますが、これはサービスの有効な定義ではありません。

WSDLはSOAPベースの操作のためのものです。純粋なHTTPで操作を公開しています。

HttpClientまたはWebClientを使用してサービスを呼び出す必要があります。

メタデータを公開する必要がある場合は、OpenAPIをご覧ください。

Microsoftは、誤解を招くようにWebHttpBindingのメタデータ機能を削除する必要があります。彼らはおそらくRESTfulな操作のためにWCFを放棄し、NancyまたはASP.Net WebAPIを使用する必要があるというシグナルではないことを示しています。

+0

私は異なる種類のバインディングを使用する必要がありますか?私はそれが生成するxmlをテストするためにブラウザで呼び出すだけです。無効です – ElenaDBA

+0

@ElenaDBA WSDLを使用してサービスを記述できるようにするには、wsHttpBindingのようなSOAPバインディングを使用する必要があります。コンシューマアプリケーションがWCFでもない場合は、basicHttpBindingを使用する必要があります。しかし、実際には、SOAPサービスであるRESTfulなサービスを使用するほうがずっと簡単です。 –

+0

@ElenaDBA - 実際には、あなたのsystem.serviceModel設定で、basicHttpBindingのバインディング設定セクションがあることがわかります。過去のある時点で基本HTTPに公開されたエンドポイントがあると仮定します。 –

関連する問題