SOAP returns data, but C# says null response

English! place to talk about OTRS development, programming and coding
Post Reply
Warlib
OTRS newbie
Posts: 20
Joined: 07 Jan 2015, 21:03
OTRS Version?: 3.3.10
Real Name: Andrey
Company: Ridan

SOAP returns data, but C# says null response

Post by Warlib »

I created simple console application and "Add service references..." to https://github.com/OTRS/otrs/blob/rel-3 ... ector.wsdl. Namespace is "OTRS".

app.config:

Code: Select all

<?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>
Simple code is:

Code: Select all

            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);
When I execute tst.SessionCreate I see in Fiddler:

Request:

Code: Select all

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>
and proper response:

Code: Select all

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>
But OTRS.OTRS_SessionCreateResponse res = tst.SessionCreate(sc) always return null. As far as I understand something is wrong with WSDL file. But I can't find the mistake. :-(

Warlib
OTRS newbie
Posts: 20
Joined: 07 Jan 2015, 21:03
OTRS Version?: 3.3.10
Real Name: Andrey
Company: Ridan

Re: SOAP returns data, but C# says null response

Post by Warlib »

I'll pay 100 USD $ if someone solve the problem.

jojo
Moderator
Posts: 14635
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: SOAP returns data, but C# says null response

Post by jojo »

you should better ask in a C# forum
"Production": OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

Warlib
OTRS newbie
Posts: 20
Joined: 07 Jan 2015, 21:03
OTRS Version?: 3.3.10
Real Name: Andrey
Company: Ridan

Re: SOAP returns data, but C# says null response

Post by Warlib »

I already published at c# firum, but unfortunately there is no any answers for now.

The problem with WSDL file which is placed: https://github.com/OTRS/otrs/blob/rel-3 ... ector.wsdl. Such kind of web interface description used from different languages and potentially the same problem occur.

jojo
Moderator
Posts: 14635
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: SOAP returns data, but C# says null response

Post by jojo »

you should not trust on automatic code generation but do the coding yourself instead. You can find an example perl code on the same place like the WSDL file
"Production": OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

Warlib
OTRS newbie
Posts: 20
Joined: 07 Jan 2015, 21:03
OTRS Version?: 3.3.10
Real Name: Andrey
Company: Ridan

Re: SOAP returns data, but C# says null response

Post by Warlib »

Manual SOAP XML parsing which responses by OTRS is not right decision. It works, but it's wrong way.
In this case I don't understand for what purpose wsdl file was created.

jojo
Moderator
Posts: 14635
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: SOAP returns data, but C# says null response

Post by jojo »

well other people (also with other programming languages) manged to use it without issues. So it seems not to be an WSDL file issue
"Production": OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

Warlib
OTRS newbie
Posts: 20
Joined: 07 Jan 2015, 21:03
OTRS Version?: 3.3.10
Real Name: Andrey
Company: Ridan

Re: SOAP returns data, but C# says null response

Post by Warlib »

I saw several examples of using SOAP web interfaces at different languages and they use manual SOAP XML parsing without using WSDL file.
Also I used tool SOAP UI which is Java based to debug responses and deserialization is also wrong.
In C# I saw that names of classes generated from WSDL file differ than names which is responded by OTRS.

jojo
Moderator
Posts: 14635
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: SOAP returns data, but C# says null response

Post by jojo »

If I create a session via Perl Script it looks like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/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>FO77jqeUi81bxi9UQMQ6NGs3AOx3p0DJ</SessionID></SessionCreateResponse></soap:Body></soap:Envelope>
"Production": OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

Warlib
OTRS newbie
Posts: 20
Joined: 07 Jan 2015, 21:03
OTRS Version?: 3.3.10
Real Name: Andrey
Company: Ridan

Re: SOAP returns data, but C# says null response

Post by Warlib »

If I create session in C# app using generated by WSDL classes I got response from OTRS:

Code: Select all

<?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>l6SFgBzxF4zBI9NwPgtR6vhrxSC59pjX</SessionID></SessionCreateResponse></soap:Body></soap:Envelope>
So, exactly the same, but deserialization doesn't work.

jojo
Moderator
Posts: 14635
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: SOAP returns data, but C# says null response

Post by jojo »

but it is a C# issue....
"Production": OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

Odrowonz
OTRS newbie
Posts: 1
Joined: 30 Jan 2015, 10:49
OTRS Version?: 4.0.3
Real Name: Андрей
Company: Центр ИТ поддержки бизнеса
Contact:

Re: SOAP returns data, but C# says null response

Post by Odrowonz »

Good afternoon. I know how to solve your problem. All the matter in the tag selection in the contract. It is necessary to rebuild the proxy under another parser. Contact me and I will explain everything in detail.

<<Добрый день. Знаю как решить вашу проблему. Все дело в теге выбора в контракте. Нужно переформировать прокси под другой парсер. Свяжитесь со мной и я все подробно объясню.>>

Warlib
OTRS newbie
Posts: 20
Joined: 07 Jan 2015, 21:03
OTRS Version?: 3.3.10
Real Name: Andrey
Company: Ridan

Re: SOAP returns data, but C# says null response

Post by Warlib »

Just for any case. I had tried to use recommendation from the article http://www.edinkapic.com/2013/06/callin ... m-net.html at the beggining of my experiments. I generated wrapper using SVCUTIL.EXE /wrapped /serializer:XmlSerializer GenericTicketConnector.wsdl but, unfortunately, I coulddn, find suitable namespaces in created *.cs file. In attached zip file Reference files generated by Visual Studio (Reference_old) and by SVCUTIL.EXE (Reference.new).

Another command line recommendation was generation from wsdl URL: svcutil /wrapped /serializer:XmlSerializer http://wsdl_url/

but I used generation from local wsdl file.
You do not have the required permissions to view the files attached to this post.

praga
OTRS newbie
Posts: 2
Joined: 23 Feb 2015, 03:49
OTRS Version?: 4.0.0.

Re: SOAP returns data, but C# says null response

Post by praga »

I managed to fix your issue. Herewith I have added the code. But this only works for CreateTicketResponse, you might have to change other parts of the code accordingly.

What changes I made
Added the correct namespace
Modified the order according to the soap response by Fiddler

Changes made

Code: Select all

[System.ServiceModel.MessageBodyMemberAttribute(Name="TicketCreateResponse", Namespace="http://www.otrs.org/TicketConnector/", Order=0)]

[System.Xml.Serialization.XmlElementAttribute(DataType="positiveInteger", Order=1)]
[System.Xml.Serialization.XmlElementAttribute(Order=2)]
[System.Xml.Serialization.XmlElementAttribute(DataType="positiveInteger", Order=0)]

Warlib
OTRS newbie
Posts: 20
Joined: 07 Jan 2015, 21:03
OTRS Version?: 3.3.10
Real Name: Andrey
Company: Ridan

Re: SOAP returns data, but C# says null response

Post by Warlib »

I wrote short article http://www.bizkit.ru/2015/02/24/2614/ where described problems with WSDL file and some recommendations. I still have some problems with several properties in OTRS_TicketGetResponse_Ticket class, and can't find suitable decision.

Thank you.

praga
OTRS newbie
Posts: 2
Joined: 23 Feb 2015, 03:49
OTRS Version?: 4.0.0.

Re: SOAP returns data, but C# says null response

Post by praga »

Did you try changing the order on those properties?

Warlib
OTRS newbie
Posts: 20
Joined: 07 Jan 2015, 21:03
OTRS Version?: 3.3.10
Real Name: Andrey
Company: Ridan

Re: SOAP returns data, but C# says null response

Post by Warlib »

Yes, I placed properties corresponding SOAP response sequence. Today I found mistake, create new WSDL file and renew zip file in my blog. It properly returns all values which return OTRS for OTRS_TicketGetResponse_Ticket class. Unfortunately in SOAP response is missed Article property (OTRS_TicketGetResponse_Article). I don't know why.

Where to get all classes properties and sequence? The OTRS developer documentation is missed some of properties and there is no sequence (order) description at all.

I have created in GitHub request to merge current WSDL file with my fork.

Post Reply