JBOSS fuse Optional tag on Interface method argument - jboss

I have two arguments to interface method
I have the following code
package com.pk.testAtrifact.incident;
public interface ServiceCountry {
/**
* Operation to country
*/
OutCountry getCountry(Header header,InputCountry input);
}
when it comes in WSDL it comes like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
<soapenv:Header/>
<soapenv:Body>
<mpos:getCountry>
<!--Optional:-->
<v1:RequestHeader>
<!--Optional:-->
There is Optional tag on RequestHeader. I dont want to keep header optional. How can i do this

Related

Use column value in M Query / Power Query

I've a short code to make a SOAP request to fetch data into Power BI. The problem is that I need to give a Session_id for the requests:
let
SourceURL = "HTTPS://SOAP.E-BOEKHOUDEN.NL/SOAP.ASMX?WSDL", //host provides this address. Url ends often with "wsdl"
options = [ #"Authorization" ="Basic USER:PASS=", //User:pass decoded with SOAP UI
#"Accept-Encoding"= "gzip,deflate",
// SOAPAction="",
#"Content-Type"="text/xml;charset=UTF-8",
#"Connection"="Keep-Alive"
],
WebContent = Web.Contents(SourceURL,
// Content options in Web.Contents() requires you to authenticate anonymously !
[Content=Text.ToBinary("
<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" xmlns:soap1=""http://www.e-boekhouden.nl/soap"">
<soap:Header/>
<soap:Body>
<soap1:OpenSession>
<!--Optional:-->
<soap1:Username>***</soap1:Username>
<!--Optional:-->
<soap1:SecurityCode1>***</soap1:SecurityCode1>
<!--Optional:-->
<soap1:SecurityCode2>***</soap1:SecurityCode2>
<!--Optional:-->
<soap1:Source></soap1:Source>
</soap1:OpenSession>
</soap:Body>
</soap:Envelope>
"),
Headers=options]) ,
XmlContent = Xml.Tables(WebContent)
in
XmlContent
Now this code is to get the Session_id. To get the other data I need to give the session_id instead of SecurityCode2 in a similar request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://www.e-boekhouden.nl/soap">
<soapenv:Header/>
<soapenv:Body>
<soap:GetMutaties>
<!--Optional:-->
<soap:SessionID>***</soap:SessionID>
<!--Optional:-->
<soap:SecurityCode1>***</soap:SecurityCode1>
<!--Optional:-->
<soap:cFilter>
</soap:cFilter>
</soap:GetMutaties>
</soapenv:Body>
</soapenv:Envelope>
Can I use a column value as parameter/variable that I can use in the body?
You don't even need a column for that. Create a query that just returns a string:
and then you can reference that query anywhere else:

SOAP request object containing null values

I am trying to implement a SOAP web service in ASP.NET Core. I generated the proxy code with dotnet svcutil and a sample request with SoapUI.
The problem is that whenever I try to post the request to my service, the request object I get is not null, but all its values are. Specifically, I am testing it with an object of this class:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="riceviPrenotazione", WrapperNamespace="http://farpresa.esterni.ised.it/", IsWrapped=true)]
public partial class riceviPrenotazioneRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://farpresa.esterni.ised.it/", Order=0)]
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public prenotazione arg0;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://farpresa.esterni.ised.it/", Order=1)]
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public infoUtente arg1;
public riceviPrenotazioneRequest()
{
}
public riceviPrenotazioneRequest(prenotazione arg0, infoUtente arg1)
{
this.arg0 = arg0;
this.arg1 = arg1;
}
}
This is the proxy implementation:
public class FederFarma : FarPreSaEsterniWs
{
public Task<riceviPrenotazioneResponse> riceviPrenotazione(riceviPrenotazioneRequest request)
{
// code...
}
public Task<eliminaPrenotazioneResponse> eliminaPrenotazione(eliminaPrenotazioneRequest request)
{
// code...
}
public Task<verificaDisponibilitaResponse> verificaDisponibilita(verificaDisponibilitaRequest request)
{
// code...
}
}
The function being called is the first one (riceviPrenotazione). Its parameter (request) is not null, but arg0 and arg1 are.
This is my interface:
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://farpresa.esterni.ised.it/", ConfigurationName="FarPreSaEsterniWs")]
public interface FarPreSaEsterniWs
{
[System.ServiceModel.OperationContractAttribute(Action="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/riceviPrenotazioneRequest", ReplyAction="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/riceviPrenotazioneResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
System.Threading.Tasks.Task<riceviPrenotazioneResponse> riceviPrenotazione(riceviPrenotazioneRequest request);
[System.ServiceModel.OperationContractAttribute(Action="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/eliminaPrenotazioneRequest", ReplyAction="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/eliminaPrenotazioneResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
System.Threading.Tasks.Task<eliminaPrenotazioneResponse> eliminaPrenotazione(eliminaPrenotazioneRequest request);
[System.ServiceModel.OperationContractAttribute(Action="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/verificaDisponibilitaRequest", ReplyAction="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/verificaDisponibilitaResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
System.Threading.Tasks.Task<verificaDisponibilitaResponse> verificaDisponibilita(verificaDisponibilitaRequest request);
}
And this is the XML I'm sending via SoapUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:far="http://farpresa.esterni.ised.it/">
<soapenv:Header/>
<soapenv:Body>
<far:riceviPrenotazione>
<!--Optional:-->
<arg0>
<!--Optional:-->
<anagrafica>
<!--Optional:-->
<cellulare>3333333333</cellulare>
<codice>123</codice>
<!--Optional:-->
<codiceFiscale>RSSMRA01A00L885A</codiceFiscale>
<!--Optional:-->
<cognome>Rossi</cognome>
<!--Optional:-->
<comuneDiNascita>
<!--Optional:-->
<codice>L885</codice>
<!--Optional:-->
<descrizione>Vignola</descrizione>
<!--Optional:-->
<fiscale>L885</fiscale>
<!--Optional:-->
<nazione>
<!--Optional:-->
<codice>ITA</codice>
<!--Optional:-->
<descrizione>Italia</descrizione>
<!--Optional:-->
<fiscale>ITA</fiscale>
</nazione>
<!--Optional:-->
<provincia>MO</provincia>
<!--Optional:-->
<regione>
<!--Optional:-->
<codice>ER</codice>
<!--Optional:-->
<descrizione>Emilia-Romagna</descrizione>
</regione>
</comuneDiNascita>
<!--Optional:-->
<domicilioCap>41057</domicilioCap>
<!--Optional:-->
<domicilioComune>
<!--Optional:-->
<codice>F257</codice>
<!--Optional:-->
<descrizione>Modena</descrizione>
<!--Optional:-->
<fiscale>F257</fiscale>
<!--Optional:-->
<nazione>
<!--Optional:-->
<codice>ITA</codice>
<!--Optional:-->
<descrizione>Italia</descrizione>
<!--Optional:-->
<fiscale>ITA</fiscale>
</nazione>
<!--Optional:-->
<provincia>MO</provincia>
<!--Optional:-->
<regione>
<!--Optional:-->
<codice>ER</codice>
<!--Optional:-->
<descrizione>Emilia-Romagna</descrizione>
</regione>
</domicilioComune>
<!--Optional:-->
<domicilioIndirizzo>Via Finta, 12</domicilioIndirizzo>
<!--Optional:-->
<nome>Mario</nome>
<!--Optional:-->
<sesso>M</sesso>
</anagrafica>
<!--Optional:-->
<codice>111</codice>
<!--Optional:-->
<!--Zero or more repetitions:-->
<listaPrenotato>
<!--Optional:-->
<prestazione>
<!--Optional:-->
<codice>222</codice>
<!--Optional:-->
<codiceRegionale>222</codiceRegionale>
<!--Optional:-->
<descrizione>Niente di che</descrizione>
<!--Optional:-->
<specialita>Nullafacentismo</specialita>
</prestazione>
<prezzoUnitario>10</prezzoUnitario>
<quantita>1</quantita>
</listaPrenotato>
<!--Optional:-->
<NRE>080A01234567890</NRE>
<!--Optional:-->
<note>Boh</note>
<prezzoTotale>10</prezzoTotale>
</arg0>
<!--Optional:-->
<arg1>
<!--Optional:-->
<nomeUtente>username</nomeUtente>
<!--Optional:-->
<password>password</password>
</arg1>
</far:riceviPrenotazione>
</soapenv:Body>
</soapenv:Envelope>
According to what I found online, this seems a namespace problem, but all namespaces seem okay to me - SoapUI is consistent with the auto-generated classes, and most importantly they were generated from the same WSDL and not modified. What could be the cause?
Looks like the same issue as mentioned on github: https://github.com/DigDes/SoapCore/issues/79 I assume from the comments you are using SoapCore
Answer was:
Just needed to change DataContractSerializer to XmlSerializer in startup:
app.UseSoapEndpoint<MyService>("/MyService.svc", new BasicHttpBinding(), SoapSerializer.DataContractSerializer);
for this:
app.UseSoapEndpoint<MyService>("/MyService.svc", new BasicHttpBinding(), SoapSerializer.XmlSerializer);
That solution worked for me.

Cannot invoke method last() on null object in soap ui

I am new to soap ui. I am trying to fetch list of files using groovy and trigger the soap UI for the same files. groovy script us running fine.but in request I am getting response stating that "Cannot invoke method last() on null object".Am I missing something:
Here is my groovy script:
def fileList = []
File theInfoName = new File("D:\\SOAP")
theInfoName.eachFile { file ->
if (file.isFile() && file.name.endsWith('.txt')) {
fileList.add(file)
}
}
log.info fileList
//context.put('fileList', fileList)
Here is my request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
<soapenv:Header/>
<soapenv:Body>
${=new File("D:\\SOAP\\" + (context.get('fileList')).last()).text}
</soapenv:Body>
</soapenv:Envelope>
but when I see in request messageExchangeResults it is showing:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
<soapenv:Header/>
<soapenv:Body>
Cannot invoke method last() on null object
</soapenv:Body>
</soapenv:Envelope>

Cannot send Soap Request as String using Retrofit 2.0

I tried sending Soap Request as String using Retrofit 2.0 but it always add myrequestString .
Do you know how to send an String SoapUI format via Retrofit 2.0?
Here is my code:
MyService.java:
#Headers({
"Content-Type: text/xml"
})
#POST
Call<ResponseBody> loadRepo(#Url String url,#Body String body);
String to send request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="">
<soapenv:Header/>
<soapenv:Body>
<web:ValidateLink>
<Request>
...
Request actual:
<string><?xml version=&apos;1.0&apos; encoding=&apos;UTF-8&apos; standalone=&apos;yes&apos; ?><soapenv:Envelope xmlns:au
...
;/soapenv:Body></soapenv:Envelope></string>
Request Expected:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="">
<soapenv:Header/>
<soapenv:Body>
<web:ValidateLink>
<Request>

JAXB Binding for SOAP request parameter in JAXWS

My task is to write a webservice for an update operation where a list of objects are passed to the method.
#WebMethod(operationName = "updateObjects", action = "urn:preferences")
public boolean updateObjects(List<MyObject> objects){
}
The class MyObject is simple enough.
#XmlRootElement(name="Object")
public class MyObject{
private String item1;
private String item2;
}
Now the problem statement. When I look at the SOAP request for this method (that SOAP UI generated for me), the request looks like below :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pref="preferences">
<soapenv:Header/>
<soapenv:Body>
<pref:updateObjects>
<!--Zero or more repetitions:-->
<arg0>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</arg0>
</pref:updateObjects>
</soapenv:Body>
</soapenv:Envelope>
but I want it to look like below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pref="preferences">
<soapenv:Header/>
<soapenv:Body>
<pref:updateObjects>
<!--Zero or more repetitions:-->
<Objects>
<Object>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</Object>
<Object>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</Object>
</Objects>
</pref:updateObjects>
</soapenv:Body>
</soapenv:Envelope>
Can somebody please advice. Thanks in advance.
You only need to add a 'wrapper' to your List of objects like this:
#XmlRootElement(name="objects")
public class MyObjects{
#XmlElement(name="object")
List<MyObject> myObjects;
}
public class MyObject{
private String item1;
private String item2;
}
NOTE: changing root element from arg0 to objects with the tag #XmlRootElement(name="objects") will not work because your <objects> is not a root element in the web service definition. Actually it is part of your <wsdl:message> (so JAXB will discart it).
What you need to change is the web service message adding a #WebParam(name = "objects") to your #WebMethod like:
#WebMethod(operationName = "updateObjects", action = "urn:preferences")
public boolean updateObjects(#WebParam(name = "objects") MyObjects objects){
}
If you do not want use a 'wrapper', you can keep your WebMethod but like this:
#WebMethod(operationName = "updateObjects", action = "urn:preferences")
public boolean updateObjects(#WebParam(name = "object") List<MyObject> objects){
}
but you will loose the <objects> wrapper. The request should be something like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pref="preferences">
<soapenv:Header/>
<soapenv:Body>
<pref:updateObjects>
<!--Zero or more repetitions:-->
<object>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</object>
</pref:updateObjects>
</soapenv:Body>
</soapenv:Envelope>