1

私のWebサービスは完全に機能しています。私が何をしたかを判断するのは困難で、その結果、時々クラッシュしました。HTTP基本認証を追加し、ObjectDBからMySQLにデータベースプロバイダーを交換したため、パフォーマンスが低下しましたが、これは無関係のようです。

MTOMストリーミングが有効になっているGlassFishv3.1でSSL保護されたJavaMetroWebサービスをホストしています。私はそれらをWCFクライアントで呼び出しています。同じパラメータで同じサービスを呼び出した場合でも、例外がランダムに発生することがあります。

UPDATE呼び出しが成功したように動作する場合があります。その後、呼び出しているサービスに関係なく、があったとしてもhelloWorld、例外が発生します。プロキシの1つだけを呼び出す場合、呼び出しは問題なく行われますが、たとえば、に電話をかけてからに電話をかけると、例外が発生しdataMiningClientますdataStoreClient。スレッドセーフ?

見る:

private void button1_Click(object sender, EventArgs e)
{
    richTextBox1.Text = "";

    DataStoreWSClient dataStoreClient = getDataStoreClient(email, password);
    DataMiningWSClient dataMiningClient = getDataMiningClient(email, password);

    byte[] dataSet = File.ReadAllBytes(textBox1.Text);
    string dataSetName = Path.GetFileName(textBox1.Text);
    long checkSum = getCheckSumForDataSet(dataSet);

    //WS Call
    try
    {
        //Example: 
        //The second time I click on this button,
        //this is the point where I get the ProtocolException
        bool checkSumResponse = dataStoreClient.checkDataSet(checkSum);

        //checkSumResponse was always true when I was debugging this
        //So no MTOM streaming involved
        if (checkSumResponse)
        {
            richTextBox1.Text = dataMiningClient.kNearestNeighbour(checkSum, notifyByEmail);
        }
        else
        {
            richTextBox1.Text = dataMiningClient.kNearestNeighbourMTOM(dataSetName, notifyByEmail, dataSet);
        }
    }
    catch (Exception ex)
    {
        //MessageBox.Show(ex.ToString());
        richTextBox1.Text = ex.ToString();
    }

    dataMiningClient.Close();
    dataStoreClient.Close();
}

サーバー側にエラーメッセージはありません。

これは私が受け取る例外メッセージです:

System.ServiceModel.ProtocolException:コンテンツタイプmultipart / related; start = ""; type = "application / xop + xml"; boundary = "uuid:d64b0098-0dcb-4da4-a047-d305b55da9f5"; start-info = "text応答メッセージの/xml"がバインディングのコンテンツタイプ(text / xml; charset = utf-8)と一致しません。カスタムエンコーダーを使用する場合は、IsContentTypeSupportedメソッドが正しく実装されていることを確認してください。応答の最初の1024バイトは次のとおりです。'--uuid:d64b0098-0dcb-4da4-a047-d305b55da9f5 Content-Id:Content-Type:application / xop + xml; charset = utf-8; type = "text / xml"コンテンツ転送エンコーディング:バイナリ

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
            xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
            xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <S:Header>
            <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
            <Action xmlns="http://www.w3.org/2005/08/addressing"
                    xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
                    S:mustUnderstand="1">http://webServices/DataStoreWS/checkDataSetResponse</Action>
            <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:1cbcfdc6-01e4-4ddc-960d-a9a2d4e3021a</MessageID>
            <RelatesTo xmlns="http://www.w3.org/2005/08/addressin'. sender, EventArgs e) in F:\2.0\WSClient3.5ServiceRef\WSClient3.5\Form1.cs:line 51

Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at WSClient3._5.DataStore.DataStoreWS.checkDataSet(checkDataSetRequest request)
   at WSClient3._5.DataStore.DataStoreWSClient.WSClient3._5.DataStore.DataStoreWS.checkDataSet(checkDataSetRequest request) in F:\Dropbox\Suli\MSc\DIPLOMA_MSc\JavaWSJMX\2.0\WSClient3.5ServiceRef\WSClient3.5\Service References\DataStore\Reference.cs:line 1227
   at WSClient3._5.DataStore.DataStoreWSClient.checkDataSet(Int64 checkSum) in F:\Dropbox\Suli\MSc\DIPLOMA_MSc\JavaWSJMX\2.0\WSClient3.5ServiceRef\WSClient3.5\Service References\DataStore\Reference.cs:line 1233
   at WSClient3._5.Form1.button1_Click(Object sender, EventArgs e) in F:\Dropbox\Suli\MSc\DIPLOMA_MSc\JavaWSJMX\2.0\WSClie

クライアントコード

DataMiningWSClient getDataMiningClient(String username, String password)
{
    //IMPORTANT - THIS LINE IS ONLY FOR TESTING PURPOSES!
    //This code is for accepting self-signed server certificate
    ServicePointManager.ServerCertificateValidationCallback += (sender_ws, cert, chain, sslPolicyErrors) => true;

    //instantiate transport binding element, leave the defaults
    HttpsTransportBindingElement transport = new HttpsTransportBindingElement();
    transport.MaxReceivedMessageSize = 2147483647;
    transport.AuthenticationScheme = AuthenticationSchemes.Basic;

    //instantiate message encoding element, where message version must be Soap11WSAddressing10 to match metro web service requirement.
    MtomMessageEncodingBindingElement mtom = new MtomMessageEncodingBindingElement();
    mtom.WriteEncoding = System.Text.Encoding.UTF8;
    mtom.MessageVersion = MessageVersion.Soap11WSAddressing10;
    mtom.MaxBufferSize = 2147483647;
    mtom.ReaderQuotas.MaxStringContentLength = 2147483647;

    //instantiate transport security binding element, with all the suggested values in app.config
    TransportSecurityBindingElement b_element = new TransportSecurityBindingElement();
    b_element.DefaultAlgorithmSuite = new Basic128SecurityAlgorithmSuite();
    b_element.IncludeTimestamp = true;
    b_element.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
    b_element.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11;
    b_element.SecurityHeaderLayout = SecurityHeaderLayout.Lax;

    //instantiate the custom binding and add the elements created above
    CustomBinding customBinding = new CustomBinding();
    customBinding.Name = "myOwnPersonalCustomBinding";
    customBinding.Elements.Add(b_element);
    customBinding.Elements.Add(mtom);
    customBinding.Elements.Add(transport);

    //instantiate the client 
    DataMiningWSClient DMclient = new DataMiningWSClient(customBinding, new EndpointAddress(new Uri("https://localhost:8181/DataMiner/DataMiner")));
    setCredentials(username, password, DMclient.ClientCredentials);
    return DMclient;
}

ここで問題になる可能性のあるヒントはありますか?この質問をさらに詳しく説明する必要があるかどうかを教えてください。WCFメッセージログを掘り下げることがあります。

4

1 に答える 1

0

理由ProtocolException:両方のプロキシをで構成しませんでしたが、両方のサービスがアノテーションMtomMessageEncodingBindingElementで定義されました。@MTOM

両方のプロキシに対してそれを定義した後、すべてが正常に機能しました。

//instantiate message encoding element, where message version must be Soap11WSAddressing10 to match metro web service requirement.
MtomMessageEncodingBindingElement mtom = new MtomMessageEncodingBindingElement();
mtom.WriteEncoding = System.Text.Encoding.UTF8;
mtom.MessageVersion = MessageVersion.Soap11WSAddressing10;
mtom.MaxBufferSize = 2147483647;
mtom.ReaderQuotas.MaxStringContentLength = 2147483647;
于 2011-11-10T21:46:03.683 に答える