Activating Proxy service consumer from ABAP - web-services

I've just created a service consumer and generated its code from ABAP in order to send to the target WSDL system XML file which is created successfully.
The code should fill in the XML_FILE_INFO fields but have no idea if I did it OK:
The code to activate it:
" Call method, and receive a response
try.
lo_proxy->SET_MESSAGE(
exporting
INPUT = gs_input
importing
OUTPUT = ls_output
).
catch CX_AI_SYSTEM_FAULT INTO lo_AI_SYSTEM_FAULT. "lo_ai_system_fault_info.
catch CX_AI_APPLICATION_FAULT INTO LO_AI_APPLICATION_FAULT.
ENDTRY.
How should I fill the XML file's content in the GS_INPUT structure? IS putting the file's path in the FILE_NAME field enough?
If someone had already done something like the mentioned requirement I'd appreciate any help.
Thanks in advance.

Related

Create mock service returning flat files

I need to build a message flow where I am supposed to trigger a message(which is combination of numbers and alphabets simply a Id no) to a URL through HTTP request node and get a flat file in response(EDI Data). I have coded and I want to test whether my flow is working.
For this I need to create a mock service and construct a flat file. My question is how I can construct the response. Any proper code to write flat files(EDI data) so that I can get that as response and make sure my flow is working.
This is how exactly my response should look like:
EDI_BA40 125566 INVOIC LS 0036566
.......... and so on
Please provide some solution so that I can receive this in my response or something that I can do to test my flow so that there would be no error when I move my code next environment(QAL/PRD).

OTRS Webservice as Requestor Test

I'm new to OTRS (3.2) and also new to PERL but I have been given the task of setting up OTRS so that it will make a call to our remote webservice so a record can be created on our end when a ticket is set as "Closed".
I set up various dynamic fields so the customer service rep can fill in additional data that will be passed into the webservice call along with ticket details.
I couldn't get the webservice call to trigger when the ticket was "Closed" but I did get it to trigger when the "priority" was changed so I'm just using that now to test the webservice.
I'm just using the Test.pm and TestSimple.pm files that were included with OTRS.
When I look at the Debugger for the Webserice, I can see that the calls were being made:
$VAR1 = {
'TicketID' => '6'
};
My webservice currently just has one method "create" which just returns true for testing.
however I get the following from the Test.pm
"Got no TicketNumber (2014-09-02 09:20:42, error)"
and the following from the TestSimple.pm
"Error in SOAP call: 404 Not Found at /TARGET/SHARE/var/otrs/Kernel/GenericInterface/Transport/HTTP/SOAP.pm line 578 (2014-09-02 09:20:43, error)
I've spent countless hours on Google but couldn't find anything on this. All I could find is code for the Test.pm and TestSimple.pm but nothing really helpful to help me create a custom invoker for my needs and configure the webservice in OTRS to get it to work.
Does anyone have any sample invokers that I can look at to see how to set it up?
Basically I need to pass the ticket information along with my custom dynamic fields to my webservice. From there I can create the record on my end and do whatever processing.
I'm not sure how to setup the Invoker to pass the necessary ticket fields and dynamic fields and how to make it call a specific method in my remote webservice.
I guess getting the Test.pm and TestSimple.pm to work is the first step then I can modify those for my needs. I have not used PERL at all so any help is greatly appreciated.
I'm also struggling with similar set of requirements too. I've also never programmed in PERL, but I can tell you at least that the "Got no TicketNumber" in the Test.pm is right from the PrepareRequest method, there you can see this block of code:
# we need a TicketNumber
if ( !IsStringWithData( $Param{Data}->{TicketNumber} ) ) {
return $Self->{DebuggerObject}->Error( Summary => 'Got no TicketNumber' );
}
You should change all references to TicketNumber to TicketID, or remove the validation whatsoever (also there is mapping to ReturnedData variable).
Invoking specific methods on your WS interface is quite simple (but poorly documented). The Invoker name that you specify in the "OTRS as requester" section of web service configuration corresponds to the WS method that will be called. So if you have WS interface with a method called "create" just name the Invoker "create" too.
As far as the gathering of dynamic field goes, can't help you on that one yet, sorry.
Cheers

SoapMessageHandler not invoked in Weblogic

I am trying to intercept SOAP message of a JWS webservice using SOAPHandlerJax-ws SoapHandler.
Below is the snapshot of what I have done.
Wrote a class JwsSoapRequestValidationHandler which extends SOAPHandler
Created HandlerConfig.xml with the below entry:
<jws:handler-chain>
<jws:handler>
<jws:handler-name>SoapRequestValidator</jws:handler-name>
<jws:handler-class>com.service.ws.jws.JwsSoapRequestValidationHandler</jws:handler-class>
</jws:handler>
</jws:handler-chain>
I have placed the xml in the same folder as my webservice.
I have annotated my webservice with #HandlerChain(file = "HandlerConfig.xml")
But strangly anf frustratingly, my handler is not invoked. I have deployed my war file in Weblogic 10.3.2
Please help me resolve this issue. I have spent 2 days without any result.......
Thanks a lot for your help.
At last, I got the solution to this problem. We need to make sure that the HandlerConfig.xml file is present in the generated artifact as well.
As soon as I included the xml in my war file, it started invoking the handler. So easy at the end :) ...
Thanks to all. Hope this will be helpful to others.

How to check if MTOM attachment is empty

I am developing webservice based on CXF. One of the requests is that client should be able to upload the optional PDF file as a part of message. This was pretty trivial:
I have added this with getter and setter to my transfer object:
#XmlMimeType("application/octet-stream")
#XmlElement(name = "InvoicePdf", required = false)
private DataHandler invoicePdf = null;
I have also enabled support for MTOM:
Endpoint endpoint = Endpoint.publish("/myWs", new WsImpl(getServletContext()));
SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
binding.setMTOMEnabled(true);
And the usage:
DataHandler pdf2 = p_invoice.getInvoicePdf();
//pdf2.getInputStream();
//pdf2.writeTo(outputstream);
Everything works great. I am able to receive and process the file. However there might be the case when client do not upload the file since it is optional. The problem is that even though the client do not sent the file I am not able to notice it.
pdf2 is not null
pdf2.getInputStream() is not null
pdf2.getInputStream() contains some data. I would like to skip parsing the input stream and looking for PDF signature. Since it is a lot easier to forward the inputstrem to desired outpustream (write to file)
I have not found in DataHandler or DataSource (pdf2.getDataSource() ) API any appropriate method or field for determining file existance. I see in debug that the empty DataHandler contains DataSource which length is 9, which is a lot less then correct PDF file. Unfortunately the length property is not accessible at all.
Any idea how to determine if the file was sent or not?
The solution is to skip xml tag for this attachment in SOAP message. So my mistake was sending empty tag:
<InvoicePdf></InvoicePdf>
Then you get behavior described in question. However if you skip this tag entirely then DataHandel is null, so I am able to distinguish is file was sent or not.

How to call Soap\WSDL Service through a login required webpage using matlab?

I am new to the wsdl\soapmessage query\reply world( if i can put it in this way), and I am facing some difficulties using the following wsdl( which I really really hope, one will be so kind to look at at least one of the services described there)
http://almdemo.polarion.com/polarion/ws/services/TrackerWebService?wsdl
which was provided to me to develop a matlab webinterface. Right now my matlab code looks like this:
targetNamespace = 'http://ws.polarion.com/TrackerWebService';
method = 'queryWorkItems';
values= {'Query','Sort'}
names = {'query', 'sort'}
types ={'xsd:string','xsd:string'}
message = createSoapMessage( targetNamespace, method, values, names, types)
response = callSoapService('http://almdemo.polarion.com/polarion/ws/services',...
% Service's endpoint
'http://almdemo.polarion.com/polarion/#/workitems',...
% Server method to run
message)
% SOAP message created using createSoapMessage
author = parseSoapResponse(response)
Herewith to save you time I will just enonce my two problems:
Is the code correct?
Could someone tell me if such a wsdl link is just a definition of webservices or it is also a service's endpoint?
Normally to execute manually\per clicks this services on the weppage
http://almdemo.polarion.com/polarion, you have to login!
So how do I send a message in matlab which first log me in? Or must such a service be introduced into that wsdl for me to do it?? Could you be kind enough to write how it must be defined, because I don't really
write wsdl files, but I shall learn!**
I will be really thankful for your help and I wish you a happy week(-end) guys(& girls)!!!
Regards
Chrysmac
ps: I tried to use Soapui and gave that webpage as endpoint, but the toool crashes each time I enter my credentials! Maybe because of the dataload!??