私はPHPサイトから安全なWCF Webサービスを浪費しています。私のPHPに関する知識は限られていますが、私はWeb上でさまざまな例を見つけましたが、まだそれらを動作させることに成功しませんでした。PHPページでカスタムユーザー名検証を使用するWCF Webサービスを使用するにはどうすればよいですか?
私は、このWebServiceも使用するSilverlightアプリケーションを持っていますが、正常に動作します。しかし、私はPHPサイトを実行すると、私はこのエラーが表示されます:
MessageSecurityException:セキュリティプロセッサは、メッセージ内のセキュリティヘッダーを見つけることができませんでした。これは、メッセージが保護されていない障害であるか、または通信相手間にバインディングの不一致があるためです。これは、サービスがセキュリティのために構成されており、クライアントがセキュリティを使用していない場合に発生します。
また、customBindingをbasicHttpBindingに変更しようとしました。私がそれをすると、カスタムユーザー名バリデーターはもはや呼び出されません。しかし、basicHttpBindingを使用し、私のWCFサービスで資格情報の検証を削除することは "機能します"(それはセキュリティ保護されていないという事実以外にも)。したがって、問題はセキュリティメッセージに関連しているようです。
誰かが私にこのPHPページを動作させるのに役立つ作業例やチュートリアルを教えてもらえますか?ここで
は私のPHPコードです:
$options = array(
'soap_version' => SOAP_1_1,
'exceptions' => true,
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'Username' => 'MyUserName',
'password' => 'MyPassword');
$client = new SoapClient('https://UrlToService/Service.svc?wsdl', $options);
try
{
$phpresponse = $client->Get();
print $phpresponse->GetResult->Version;
echo "</b><BR/><BR/>";
}
catch(Exception $e)
{
echo "<h2>Exception Error!</h2></b>";
echo $e->getMessage();
echo "<BR/><BR/>";
}
WCFの設定
<behavior name="sslBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyNamespace.ServiceUserNameValidator, MyNamespace" />
</serviceCredentials>
<serviceSecurityAudit
auditLogLocation="Application"
serviceAuthorizationAuditLevel="Failure"
messageAuthenticationAuditLevel="Failure"
suppressAuditFailure="true" />
</behavior>
<customBinding>
<binding name="sslCustomBinding">
<security authenticationMode="UserNameOverTransport" includeTimestamp="true" allowInsecureTransport="true">
<localServiceSettings maxClockSkew="00:10:00" />
<localClientSettings maxClockSkew="00:10:00" />
<secureConversationBootstrap />
</security>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport />
</binding>
</customBinding>
<service behaviorConfiguration="sslBehavior" name="MyNamespace.Services.Service">
<endpoint address="" binding="customBinding"
bindingConfiguration="sslCustomBinding" contract="MyNamespace.ServiceContracts.IService" />
<host>
<baseAddresses>
<add baseAddress="https://UrlToService/Services/" />
</baseAddresses>
</host>
</service>
YEEEEEEES ITが私を助けました! –
これも私を助けました!素晴らしい解決策! – Trond