Страница 1 из 1

SOAP возвращает результат, но в C# переменная null

Добавлено: 10 янв 2015, 18:29
Warlib
Подробно описал проблему здесь http://forums.otterhub.org/viewtopic.php?f=64&t=27661. Дублирую.

Сделал тестовое консольное приложение. Добавил ссылку на сервис "Add service references...", указав namespace "OTRS" https://github.com/OTRS/otrs/blob/rel-3 ... ector.wsdl

app.config:

Код: Выделить всё

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="GenericTicketConnector_Service">
                    <textMessageEncoding messageVersion="Soap12" writeEncoding="utf-8" />
                    <httpTransport authenticationScheme="Negotiate" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://server/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector"
                binding="customBinding" bindingConfiguration="GenericTicketConnector_Service"
                contract="OTRS.GenericTicketConnector_Interface" name="GenericTicketConnector_endPoint" />
        </client>
    </system.serviceModel>
</configuration>
C# код:

Код: Выделить всё

            OTRS.GenericTicketConnector_InterfaceClient tst = new OTRS.GenericTicketConnector_InterfaceClient();
            OTRS.OTRS_SessionCreate sc = new OTRS.OTRS_SessionCreate();
            sc.ItemElementName = OTRS.ItemChoiceType8.UserLogin;
            sc.Item = "soap";
            sc.Password = "1234567";
            OTRS.OTRS_SessionCreateResponse res = tst.SessionCreate(sc);
При запуске tst.SessionCreate в Fiddler:
в запросе

Код: Выделить всё

POST http://server/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8; action="http://www.otrs.org/TicketConnector/SessionCreate"
Accept-Encoding: gzip, deflate
Authorization: Negotiate YIIJD...
Host: server
Content-Length: 593
Expect: 100-continue

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo4PEabC5oGtEiCOwnHEOmXwAAAAAvK+FPsGFCEOmZUNvMy/N/J/fhkSfwzNJpaMe4vDOM+AACQAA</VsDebuggerCausalityData></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><SessionCreate><UserLogin xmlns="http://www.otrs.org/TicketConnector/">soap</UserLogin><Password xmlns="http://www.otrs.org/TicketConnector/">1234567</Password></SessionCreate></s:Body></s:Envelope>
в корректном ответе:

Код: Выделить всё

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=UTF-8
Content-Length: 508
Connection: close

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><SessionCreateResponse xmlns="http://www.otrs.org/TicketConnector/"><SessionID>93gUJnw5fa9EaZzs59B1FBvwV4re2V1o</SessionID></SessionCreateResponse></soap:Body></soap:Envelope>
Но код OTRS.OTRS_SessionCreateResponse res = tst.SessionCreate(sc) всегда возвращает null. Судя по всему есть какие-то проблемы с WSDL файлом, но ошибки найти не могу. :-(

Re: SOAP возвращает результат, но в C# переменная null

Добавлено: 28 янв 2015, 06:49
Warlib
За решение вопроса готов заплатить 100$.