[SOLVED] Otrs send soap message to webservice

Moderator: crythias

Post Reply
MaxMaz
Znuny newbie
Posts: 30
Joined: 08 Sep 2015, 17:06
Znuny Version: 3.3.9

[SOLVED] Otrs send soap message to webservice

Post by MaxMaz »

Hello everyone my problem is on soap message generated from OTRS.

this is my otrs soap message

Code: Select all

<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>
<namesp1:Method02 xmlns:namesp1="http://tempuri.org">
<TicketID>1242</TicketID>
</namesp1:Method02>
</soap:Body>
</soap:Envelope>
The problem is here

Code: Select all

<TicketID>1242</TicketID>
The element TicketID has not namespace. It means that my webservice get TicketID null

This is my interface webservice method

Code: Select all

void Method02([XmlElement(Namespace="")] string TicketID);
and my method

Code: Select all

       
        public void Method02([XmlElement(Namespace="")] string TicketID)
        {
            //....
        }
i used suggests reading this post but it doens't works
viewtopic.php?f=64&t=29445&p=119320&hil ... ce#p119320
Last edited by MaxMaz on 21 Sep 2015, 09:01, edited 1 time in total.
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Otrs send soap message to webservice

Post by eandrex »

Does your .Net Webservice namespace match the one you defined in OTRS?

in your .Net you should have something like this(at the very begining)
[WebService(Namespace = "http://example.com/Whatever")]

then you must define "http://example.com/Whatever" in your "OTRS as Invoker" protococol(HTTP::SOAP) configuration

also make sure your SOAP Separator is set to "/".

And by the way, what are you expecting as result and what are you getting instead? "What" does not work exactly?.. what do logs say?
MaxMaz
Znuny newbie
Posts: 30
Joined: 08 Sep 2015, 17:06
Znuny Version: 3.3.9

Re: Otrs send soap message to webservice

Post by MaxMaz »

eandrex wrote:Does your .Net Webservice namespace match the one you defined in OTRS?

in your .Net you should have something like this(at the very begining)
[WebService(Namespace = "http://example.com/Whatever")]

then you must define "http://example.com/Whatever" in your "OTRS as Invoker" protococol(HTTP::SOAP) configuration

also make sure your SOAP Separator is set to "/".

And by the way, what are you expecting as result and what are you getting instead? "What" does not work exactly?.. what do logs say?
Hello im waiting as result ticketID (look At parametEr method in my webservice)
While i get null

The problem is on this Line of the soap message

Code: Select all

<TicketID>1242</TicketID>
I should have this Line to work fine (look At soap message first post)

Code: Select all

<namesp1:TicketID>1242</namesp1:TicketID>
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Otrs send soap message to webservice

Post by eandrex »

Does your method in your .Net webservice project has [WebMethod] before its signature? (I know it may be logic, but it is better to discard that)..because the forum post you referenced in your first message solves the problem (if everything is configured right)..

Can you provide full OTRS as Invoker Config?
Maybe post more code in your .Net Webservice? to try to replicate your issue

Also, please note que we are talking about .Net related stuff, and that may be out of the scope of this forum
MaxMaz
Znuny newbie
Posts: 30
Joined: 08 Sep 2015, 17:06
Znuny Version: 3.3.9

Re: Otrs send soap message to webservice

Post by MaxMaz »

eandrex wrote:Does your method in your .Net webservice project has [WebMethod] before its signature? (I know it may be logic, but it is better to discard that)..because the forum post you referenced in your first message solves the problem (if everything is configured right)..

Can you provide full OTRS as Invoker Config?
Maybe post more code in your .Net Webservice? to try to replicate your issue

Also, please note que we are talking about .Net related stuff, and that may be out of the scope of this forum
Is not a webmethod (old webservice) but a wcf

My actual invoker is testsimple.pm maybe have to Change it
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Otrs send soap message to webservice

Post by eandrex »

Mmm, I dont know a lot about WCF, so i cant help you with it, however, the other option left is to modify https://github.com/OTRS/otrs/blob/rel-3 ... TP/SOAP.pm to add the namespace.

Ill try that later today
MaxMaz
Znuny newbie
Posts: 30
Joined: 08 Sep 2015, 17:06
Znuny Version: 3.3.9

Re: Otrs send soap message to webservice

Post by MaxMaz »

eandrex wrote:Mmm, I dont know a lot about WCF, so i cant help you with it, however, the other option left is to modify https://github.com/OTRS/otrs/blob/rel-3 ... TP/SOAP.pm to add the namespace.

Ill try that later today
Oh should be Great!!!!! Le me know if you make this up date! !!!!!!
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Otrs send soap message to webservice

Post by eandrex »

Hello, I managed to do something that made the 'trick'

Affected file: <OTRS_ROOT>/Kernel/GenericInterface/Transport/HTTP/SOAP.pm

To see what changed in that file, look over: https://www.diffchecker.com/xcerj4nt

Changes can be seen in lines: 447, 565, 571

if you dont want to override the default file, copy it into

<OTRS_ROOT>/Custom/Kernel/GenericInterface/Transport/HTTP/ (create directory tree if it doesnt exists)

modify it, run otrs.SetPermissions.pl and restart your webservice

Hope it helps
MaxMaz
Znuny newbie
Posts: 30
Joined: 08 Sep 2015, 17:06
Znuny Version: 3.3.9

Re: Otrs send soap message to webservice

Post by MaxMaz »

eandrex wrote:Hello, I managed to do something that made the 'trick'

Affected file: <OTRS_ROOT>/Kernel/GenericInterface/Transport/HTTP/SOAP.pm

To see what changed in that file, look over: https://www.diffchecker.com/xcerj4nt

Changes can be seen in lines: 447, 565, 571

if you dont want to override the default file, copy it into

<OTRS_ROOT>/Custom/Kernel/GenericInterface/Transport/HTTP/ (create directory tree if it doesnt exists)

modify it, run otrs.SetPermissions.pl and restart your webservice

Hope it helps
Sorry i dont understand, i dont see nothing
where is your SOAP.pm?
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Otrs send soap message to webservice

Post by eandrex »

Copy <OTRS_ROOT>/Kernel/GenericInterface/Transport/HTTP/SOAP.pm
to
<OTRS_ROOT>/Custom/Kernel/GenericInterface/Transport/HTTP/ Create that directory tree if it doesnt exist in your system

Edit <OTRS_ROOT>/Custom/Kernel/GenericInterface/Transport/HTTP/SOAP.pm

Change this line

https://github.com/OTRS/otrs/blob/rel-3 ... AP.pm#L447

To

Code: Select all

my $SOAPMethod = SOAP::Data->name( $Param{Operation} )->uri( $Config->{NameSpace} )->prefix('ns1');
Change this line

https://github.com/OTRS/otrs/blob/rel-3 ... AP.pm#L565

To

Code: Select all

push @CallData, $DataPart->attr({'xmlns:ns1' => $Config->{NameSpace}})->prefix('ns1');
And finally change this line

https://github.com/OTRS/otrs/blob/rel-3 ... AP.pm#L571

to

Code: Select all

push @CallData, $SOAPData->{Data}->attr({'xmlns:ns1' => $Config->{NameSpace}})->prefix('ns1');
Set perrmissions (running otrs.SetPermissions.pl)
Restart your webserver and try invoking the webservice

In my test environment it sends this

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope 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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <soap:Body>
      <ns1:Method2 xmlns:ns1="Test">
         <ns1:TicketNumber>2015091810000216</ns1:TicketNumber>
      </ns1:Method2>
   </soap:Body>
</soap:Envelope>
Hope it helps

Edit: I didnt attacht my SOAP.pm to avoid "trust" issues..it is better if you edit it yourself..that way you know what changed
MaxMaz
Znuny newbie
Posts: 30
Joined: 08 Sep 2015, 17:06
Znuny Version: 3.3.9

Re: Otrs send soap message to webservice

Post by MaxMaz »

nice!!!! Monday i will try!!! Thanks for now

you have been very usefull
MaxMaz
Znuny newbie
Posts: 30
Joined: 08 Sep 2015, 17:06
Znuny Version: 3.3.9

Re: Otrs send soap message to webservice

Post by MaxMaz »

eandrex it workkkkkkkkkks!!!!!!!!!!!!

thanks!!!

ps.
eandrex i sended a pm :)
Post Reply