Run .Net Web Service from OTRS

English! place to talk about development, programming and coding
Post Reply
jsw
Znuny newbie
Posts: 5
Joined: 15 Jun 2015, 16:04
Znuny Version: otrs4

Run .Net Web Service from OTRS

Post by jsw »

I try to call VS .Net Web Service on OTRS triger ( e.g. TicketCreate, ArticleCreate ).
1. I've got web function: string newOTRSTest(string TicketID)

2. I've configured Invoker ( TestSimple.pm) for events.
3. In the invoker I've added a key mapping TicketID=>TicketID

But when the invoker it's generated SOAP

<?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>
<namesp26:newOTRSTest xmlns:namesp26="http://tempuri.org">
<TicketID>20</TicketID>
</namesp26:newOTRSTest></soap:Body></soap:Envelope>

Calling the function newOTRSTest has marked as namespace but attributs TicketID has without namespace name.

How to make its the same - both with or without namespace addition name?
jsw
Znuny newbie
Posts: 5
Joined: 15 Jun 2015, 16:04
Znuny Version: otrs4

Re: Run .Net Web Service from OTRS

Post by jsw »

Ofcourse .Net Web Method couldn't found the parameter value due namespace.
TicketID is null, so the function will not work property at all.
Has anybody any idea for solution?
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Run .Net Web Service from OTRS

Post by eandrex »

Well, you would have to edit the function definition on your .Net Code...and it is a .Net related question :).. but i went trhought same problem weeks ago, and here it is, your solution:

In your .net web service, preppend this to your arguments

Code: Select all

[XmlElement(Namespace="")]
jsw
Znuny newbie
Posts: 5
Joined: 15 Jun 2015, 16:04
Znuny Version: otrs4

Re: Run .Net Web Service from OTRS

Post by jsw »

I try to add empty namespace into web service class definition
  • public class OTRS : System.Web.Services.WebService
    {
    [XmlElement(Namespace="")]
    .....
But when I call web metod with SOAP biody like this:
  • <s11:Body>
    <ns1:newOTRSTest xmlns:ns1='http://tempuri.org/'>
    <TicketID>3</TicketID>
    </ns1:newOTRSTest>
    </s11:Body>
Inside the web method newOTRSTest param TicketID is steel NULL.

Where I should to add this empty XmlElement ?
jsw
Znuny newbie
Posts: 5
Joined: 15 Jun 2015, 16:04
Znuny Version: otrs4

Re: Run .Net Web Service from OTRS

Post by jsw »

In the project I've got
using System.Xml.Serialization;
so
XmlElement
means System.Xml.Serialization.XmlElement
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Run .Net Web Service from OTRS

Post by eandrex »

You are adding [XmlElement(Namespace="")] in the wrong place. Add it before every argument your webmethod takes.

For example

Code: Select all

..
public .. MethodName([XmlElement(Namespace="")]int TicketID, 
 [XmlElement(Namespace="")]string SLA){
..
..
}
jsw
Znuny newbie
Posts: 5
Joined: 15 Jun 2015, 16:04
Znuny Version: otrs4

Re: Run .Net Web Service from OTRS

Post by jsw »

Thanks for all.
Everything works properly.
Your answer was brilliant.
Post Reply