3

別のサーバーに .NET ASMX Web サービスがあり、ミュール スタンドアロン CE 3.4 を別のサーバーにインストールしました。この .NET Web サービスを呼び出して 2 つの文字列パラメーターを渡す必要がある非常に単純なフローがあります。

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd">
    <custom-transformer returnClass="java.lang.String[]" mimeType="text/plain" class="com.rms.corpapps.utils.WebServiceParamsTransformer" name="Java" doc:name="Java"/>
<http:connector name="httpConnector" enableCookies="true" proxyHostname="myserver" proxyUsername="domain\myusername" proxyPassword="mypassword" proxyPort="80" >
    <spring:property name="proxyNtlmAuthentication" value="true"/>
</http:connector>
<flow name="sftestFlow1" doc:name="sftestFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" path="flows/sftest"/>
    <custom-transformer class="com.mycompany.utils.WebServiceParamsTransformer" doc:name="Transform Data for web service" doc:description="This java component prepares the input for web service"/>
    <cxf:jaxws-client doc:name="SOAP"
        clientClass="com.mycompany.WebServiceListener" port="WebServiceListenerSoap"  operation="ProcessExternalMessage"
    />
    <outbound-endpoint address="http://myserver/sm/webservicelistener.asmx?wsdl" doc:name="Generic" exchange-pattern="request-response" connector-ref="httpConnector"/>
</flow>

基本的に、フローを呼び出すために http インバウンド エンドポイントを (テスト目的で) 公開し、Web サービスに渡す必要がある文字列を返す Java トランスフォーマー クラスを使用しています。WebServiceParamsTransformer クラスのコードを次に示します。

public class WebServiceParamsTransformer extends AbstractTransformer {
    @Override
    public Object doTransform(Object src, String encoding) throws TransformerException {
        Object[] out = new Object[2];
    out[0] = "Update Ticket Service";
    out[1] = Base64.encode("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><event source=\"SHUB\" target=\"TP\" type=\"SUB8\" version=\"1.0\" timestamp=\"2013-09-16T15:52:14.0000+00.00\"><new-eta-event><incident-number>123456</incident-number><user-name>hari</user-name><eta-timestamp>2013-09-16T15:52:14.0000+00.00</eta-timestamp></new-eta-event></event>");

    return out;
    }
}

残念ながら、これは機能していません。「応答コード: 401。権限がありません」というエラーが表示されます。エラーログからの抜粋は次のとおりです。

INFO  2013-09-17 13:54:13,396 [[sftest].httpConnector.receiver.02] org.apache.commons.httpclient.auth.AuthChallengeProcessor: **ntlm authentication scheme selected**
INFO  2013-09-17 13:54:13,397 [[sftest].httpConnector.receiver.02] org.apache.commons.httpclient.HttpMethodDirector: **No credentials available for NTLM <any realm>@myserver:80**
INFO  2013-09-17 13:54:13,397 [[sftest].httpConnector.receiver.02] org.mule.transport.http.HttpClientMessageDispatcher: **Received a redirect, but followRedirects=false. Response code: 401 Unauthorized**
WARN  2013-09-17 13:54:13,398 [[sftest].httpConnector.receiver.02] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://tempuri.org/}WebServiceListener#{http://tempuri.org/}ProcessExternalMessage has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Response was of unexpected text/html ContentType.  Incoming portion of HTML stream: **You do not have permission to view this directory or page.**

.NET Web サービスは、Windows 統合認証によって保護され、.NET Framework 2.0 の Windows Server 2008 の IIS 7 で実行されます。認証設定を示すスクリーンショットを次に示します。

ここに画像の説明を入力

私はどこで間違っていますか?私の要件は、mule esb からの統合認証によって保護された Web サービスを単純​​に呼び出すことです。どんな助けでも大歓迎です。

4

1 に答える 1

2

これは、認証例外が原因で発生します。

<cxf:jaxws-client operation="Get_Workers"
            clientClass="com.saba.workday.ws.human_resources.HumanResourcesService"
            port="Human_Resources" wsdlLocation="classpath:Human_Resources.wsdl"
            doc:name="Get_Workers">
            <cxf:outInterceptors>
                <spring:ref bean="CredentialsSupplierBean" />
            </cxf:outInterceptors>
        </cxf:jaxws-client>

ここで Credential Supplier は、WSS4JOutInterceptor を拡張する Bean です。そして認証を行います。

クレデンシャル サプライヤー:

public class CredentialsSupplier extends WSS4JOutInterceptor {

 public CredentialsSupplier() {
    setProperty("action", "UsernameToken");
    setProperty("passwordType", "PasswordText");
 }

    @Override
    public void handleMessage(SoapMessage message) {
        super.handleMessage(prepareHandleMessage(message));
    }

    protected SoapMessage prepareHandleMessage(SoapMessage message) {
            message.setContextualProperty("user", "username");
            message.setContextualProperty("password", "pswd");
        return message;
    }
}
于 2013-09-18T03:55:59.577 に答える