Модераторы: gambit
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Web Service Extension не вызывается 
V
    Опции темы
Bogdan1024
  Дата 29.10.2008, 15:00 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Завсегдатай
Сообщений: 1436
Регистрация: 28.9.2005
Где: Киев

Репутация: 2
Всего: 13



Код

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Web.Services.Description;
using System.Xml;
[WebService(Name = "MyWebService", Description = "This web service is used to experi,ment with some of the Web service concepts.", Namespace = "http://www.mycompany.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class MyWebService : System.Web.Services.WebService
{
    [CustomSoapExtension.TestSoapExtension()]
    [WebMethod()]
    public string HelloWorld()
    {
        return "Hello, World!";
    }
}


Код

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services.Protocols;
using System.IO;

namespace CustomSoapExtension
{
    public class CustomSoapExtension : SoapExtension
    {
        System.IO.Stream OldStream;
        System.IO.Stream NewStream;
        public override object GetInitializer(Type serviceType)
        {
            return null;
        }
        public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute)
        {
            return null;
        }

        public override void Initialize(object initializer)
        {
            
        }

        public override void ProcessMessage(SoapMessage message)
        {
            System.IO.Stream s = message.Stream;
            string mt = (message.GetType() == typeof(SoapServerMessage)) ? "Server Message" : "Client Message";
            switch (message.Stage)
            {
                case SoapMessageStage.BeforeSerialize:
                    s.Seek(0, SeekOrigin.Begin);
                    WriteToLog("Before Serialize: (" + mt + ")", s);
                    s.Seek(0, System.IO.SeekOrigin.Begin);
                    break;
                case SoapMessageStage.AfterDeserialize:
                    break;
                case SoapMessageStage.BeforeDeserialize:
                    s.Seek(0, SeekOrigin.Begin);
                    WriteToLog("Before Deserialize: (" + mt + ")", s);
                    s.Seek(0, SeekOrigin.Begin);
                    break;
                case SoapMessageStage.AfterSerialize:
                    break;
            }
        }
        private void WriteToLog(string t, Stream s)
        {
            StreamReader sr = new StreamReader(s);
            Settings1 s1 = new Settings1();
            StreamWriter sw = new StreamWriter(s1.LoggingFile, true);
            sw.Write("**** " + t + "\r\n" + sr.ReadToEnd() + "\r\n\r\n");
            sw.Close();
        }
        public override System.IO.Stream ChainStream(System.IO.Stream stream)
        {
            this.NewStream = stream;
            this.OldStream = new System.IO.MemoryStream();
            return this.OldStream;
        }
    }
}

Код

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services.Protocols;

namespace CustomSoapExtension
{
    [AttributeUsage(AttributeTargets.Method)]
    public class TestSoapExtensionAttribute    : SoapExtensionAttribute
    {

        public override Type ExtensionType
        {
            get { return typeof(CustomSoapExtension); }
        }

        public override int Priority
        {
            get {return 1;}
            set{}
        }
    }
}

Так вот, при вызове метода веб-сервиса HelloWorld WebServiceExtension судя по всему не вызывается. Ничего не пишется в файл. Дебагер не останавлияется на брэйкпойнтах в процедуре "Process". Почему?


--------------------
user posted image
PM MAIL   Вверх
Bogdan1024
Дата 2.11.2008, 15:53 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Завсегдатай
Сообщений: 1436
Регистрация: 28.9.2005
Где: Киев

Репутация: 2
Всего: 13



Исправил. Как - не помню smile


--------------------
user posted image
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Прежде чем создать тему, посмотрите сюда:
cully
mr.DUDA
Exception

Используйте теги [code=csharp][/code] для подсветки кода. Используйтe чекбокс "транслит" если у Вас нет русских шрифтов.

Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, cully, mr.DUDA, Exception.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Распределённые приложения и сеть | Следующая тема »


 




[ Время генерации скрипта: 0.0382 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.