Problems with Spring Integration HTTP outbound channel adapter - http

I am using spring integration 2.2.4 and am trying to add HTTP outbound channel adapter for invoking GET/POST REST services. Currently the adapter is getting displayed in the graph view but when I am trying to drag and use it in the code , it is not getting created.
I have added the HTTP namespaces URI as required.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http="http://www.springframework.org/schema/integration/http"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/http
http://www.springframework.org/schema/integration/http/spring-integration-http.xsd">
<http:outbound-channel-adapter channel=""/>
If I am trying to add this manually in the source XML then I am getting error as "The matching wildcard is strict , but no declaration could be found for element http:outbound-channel-adapter"
Can anyone help me out here with a sample http-outbound channel adapter? Am I missing something here.

Related

Issue ticket from Sabre API

I am trying to implement an application to book flights using Sabre API. I have successfully created the PNR and am moving towards issuing tickets. I followed the listed workflow to book and issue ticket.
BargainFinderMaxRQ to find the flights
PassengerDetailsRQ to generate PNR
EnhancedAirBookRQ to book the flight segment
To issue ticket I am following this workflow:
TravelItineraryReadRQ to get PNR
DesignatePrinterLLSRQ to designate a printer(Even though i do not want to designate a printer as I only require e-tickets)
AirTicketLLSRQ to issue tickets
EndTransactionLLSRQ to end the transaction and send email
I am stuck for a couple of days in issuing the ticket and have been working a lot to overcome but through one or more steps I somehow do get stuck somewhere. Right now I am stuck at DesignatePrinterLLSRQ which says ERR.SWS.CLIENT.VALIDATION_FAILED.
Attached are my xml logs:
Request Body:
<SOAP-ENV:Body>
<DesignatePrinterRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0.1">
<Printers>
<BagTag LNIATA=""/>
</Printers>
</DesignatePrinterRQ>
<DesignatePrinterRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0.1">
<Printers>
<BagTag Undesignate="true"/>
</Printers>
</DesignatePrinterRQ>
</SOAP-ENV:Body>
Response:
<soap-env:Body>
<soap-env:Fault>
<faultcode>soap-env:Client.Validation</faultcode>
<faultstring>ERR.SWS.CLIENT.VALIDATION_FAILED</faultstring>
<detail>
<stl:ApplicationResults xmlns:stl="http://services.sabre.com/STL/v01" status="NotProcessed">
<stl:Error timeStamp="2017-02-10T02:35:51-06:00" type="Validation">
<stl:SystemSpecificResults>
<stl:Message>Request resulted in empty Host Command</stl:Message>
<stl:ShortText>ERR.SWS.CLIENT.VALIDATION_FAILED</stl:ShortText>
</stl:SystemSpecificResults>
</stl:Error>
</stl:ApplicationResults>
</detail>
</soap-env:Fault>
</soap-env:Body>
If it is possible, do let me know if there is an issue with my workflow.
Regards
There is one important error and even if you are not getting the same error anymore it is important to highlight.
In your request, you attempting to call the service more than once and that is not correct. You are opening the DesignatePrinterRQ tag twice and that will not work, because after closing the first DesignatePrinter nothing else is expected.
Below is your request:
<SOAP-ENV:Body>
<DesignatePrinterRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0.1">
<Printers>
<BagTag LNIATA=""/>
</Printers>
</DesignatePrinterRQ>
<DesignatePrinterRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0.1">
<Printers>
<BagTag Undesignate="true"/>
</Printers>
</DesignatePrinterRQ>
</SOAP-ENV:Body>
Below is how it should be:
<SOAP-ENV:Body>
<DesignatePrinterRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0.1">
<Printers>
<BagTag LNIATA=""/>
</Printers>
</DesignatePrinterRQ>
</SOAP-ENV:Body>
--
Now, I am not sure for which kind of customer you are developing but BagTag printer is only meant for airlines to use, not travel agencies. You will just need to send something like this before issuing the ticket:
<SOAP-ENV:Body>
<DesignatePrinterRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0.1">
<Printers>
<Ticket CountryCode="AT">
</Printers>
</DesignatePrinterRQ>
</SOAP-ENV:Body>
In order to check which CountryCode should you use, please check on the
Format Finder. (You should be able to use the same credentials you use for creating sessions)
If, at the time of issuing the ticket you get something like Designate HardCopy printer, get in touch with Sabre for them to try and disable the hardcopy printing.
Sabre has the concept of virtual printers, which are not physical printers and are suitable for cases like this, where you don't want something to be actually printed. You need to get sabre to configure virtual printers and give you the line addresses for them.
Your workflow for ticketing should be...
Get a sabre session
Designate a printer. You may need to change your duty code to 4 or 5 before this otherwise printer designation can fail.
Call AirTicket
EndTransaction
Make sure your itinerary is quoted before issuing a ticket.
When designating a printer, you need to specify the country code and the line address. Some code I use for doing this is below...
// Assign a printer
DesignatePrinterRQ designatePrinterRQ = new DesignatePrinterRQ();
designatePrinterRQ.setVersion("2003A.TsabreXML1.2.1");
Printers printers = new Printers();
designatePrinterRQ.setPrinters(printers);
Ticket ticketPrinter = new Ticket();
printers.setTicket(ticketPrinter);
ticketPrinter.setCountryCode("2A");
ticketPrinter.setLineAddress("99999901234540");
In the above code, 999999 is a virtual printer and 01234540 is the station code of the sabre session.

Differences in validating APIKeys with GetOAuthV1Info and VerifyAPIKey

We are in the process of totally rewriting our main API Proxy config and we discovered an issue with our new configuration (or maybe our existing one) relating to how API keys are being validated. Our current API uses the policy GetOAuthV1Info
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<GetOAuthV1Info enabled="true" continueOnError="false" async="false" name="APIKey-Validate">
<DisplayName>APIKey-Validate</DisplayName>
<FaultRules/>
<Properties/>
<AppKey ref="request.queryparam.apikey"></AppKey>
</GetOAuthV1Info>
Our new configuration uses the policy VerifyAPIKey
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<VerifyAPIKey async="false" continueOnError="false" enabled="true" name="Verify-Api-Key">
<DisplayName>Verify API Key</DisplayName>
<APIKey ref="request.queryparam.apikey"/>
</VerifyAPIKey>
On the surface both of these policies appear to work fine. However, after deploying the new config to our test environment some API keys were failing with a 401 Unauthorized error. Digging into those keys we discovered that they are assigned to a product that doesn't have access to the test environment. It appears that the GetOAuthV1Info step is not validating the environment..? The documentation for GetOAuthV1Info doesn't help as it doesn't talk about APIKeys at all (http://apigee.com/docs/api-services/content/authorize-requests-using-oauth-10a).
Fixing this particular issue is pretty straight forward in that we just need to allow those other products access to the test environment. However, this makes me wonder what the other differences are between these two policies? I'm very nervous now about deploying any changes to these API proxies because I don't know what else will break, or what other unforeseen issues will appear.
Is this a known limitation with the GetOAuthV1Info policy? Why does this even work at all? What are the other differences between these two policies that might bite me later?
The only difference that I'm aware of is that the variable names are assigned differently in the VerifyAPIKey Policy (it appends the policy type and name to the vairalbes like verifyapikey.verify_apikey-1.apiproduct.developer.quota.limit for example).
Both VerifyAPIKey and OAuth 1 does support restrictions by environment -- when I tested the GetOAuthV1 with an APIKey in an invalid environment and got this error:
OAuth Failure : Invalid API call as no apiproduct match found
Keep in mind that the convention for most projects seems to be either OAuth2 flows or the VerifyAPI so there is less information about the OAuth1 policies.

understanding AMFChannel in flex and message broker

I need to use AMFChannel in order to connect to RemoteObject in flex tried searching a lot but couldn;t get source to understand the two parameters being passed to the constructor ... I am using spring framework as a backend for my GUI created using flex .... canm some one explain me this integration of flex with spring or guide me to a proper resource to understand it... through which I can understand the overall scenerio... or atleast understand how this call is being made using message broker . PLEASE SOME ONE HELP ME BY TELLING ME WHAT IS THE MEANING OF URL WE ARE PASSING TO THE AMF CHANNEL CONSTRUCTOR
This link might help some one.
The MessageBroker transparently handles the process of serialization and deserialization between the Flex AMF data format and Java.
This link explains everything with help of example which was exactly what I was looking for
some important setup information is as follows
Server side has following files
* testdrive/src/main/webapp/WEB-INF/spring/app-config.xml
* testdrive/src/main/webapp/WEB-INF/flex-servlet.xml
* testdrive/src/main/java/flex/spring/samples/product/ProductDAO.java
Client side has one file which looks like this
Step1) Initialize a messagebroker in flex-servlet.xml
<flex:message-broker>
<flex:message-service
default-channels="my-streaming-amf,my-longpolling-amf,my-polling-amf" />
<flex:secured />
</flex:message-broker>
Step2) In the same flex-servlet.xml specify one tag
<flex:remoting-destination ref="productService" />
Step 3) In app-config.xml
<bean id="contactService" class="org.springframework.flex.samples.product.ProductDAO">
<constructor-arg ref="dataSource" />
</bean>
Step 4) ProductDAO.java is the class which will exposed for the remoting
Client side can call the remote object as follows
Step 5)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<!-- "productService" is defined in Spring's configuration file WEB-INF/config/web-application-config.xml
and provides remote access to the org.springframework.flex.samples.product.ProductDAO class -->
<mx:RemoteObject id="ro" destination="productService"/>
<mx:DataGrid dataProvider="{ro.findAll.lastResult}" width="100%" height="100%"/>
<!-- the findAll() method is defined in org.springframework.flex.samples.product.ProductDAO -->
<mx:Button label="Get Data" click="ro.findAll()"/>
</mx:Application>

ASP.Net Web Service - What is the correct way to add a detail element to a SOAP fault response that works for both SOAP 1.1 and SOAP 1.2?

ASP.Net 2.0 Web Services automatically create both SOAP 1.1 and SOAP 1.2 bindings. Our web service, however, has SOAP extensions and custom exception handling that make the assumption that only the SOAP 1.1 binding is used (for example, the SOAP extension uses the HTTP SOAPAction header to control behavior).
I am looking to correct the code that makes these assumptions and make it work with either SOAP 1.1 or SOAP 1.2 properly. I am running into a bit of a problem in the generation of elements for our SOAP faults.
Consider the following web method implementation:
[WebMethod]
public void
ThrowsSoapException()
{
throw new SoapException("This is a SOAP exception.", SoapException.ServerFaultCode);
}
Invoking this via SOAP 1.1 yields the following result:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>This is a SOAP exception.</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Invoking via SOAP 1.2 yields the following result:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Receiver</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">This is a SOAP exception.</soap:Text>
</soap:Reason>
<soap:Detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
In both these cases there is an empty detail element as a child of the <soap:Fault> element, but it has a different qualified name, either <detail> or <soap:Detail>.
Now consider the following code that tries to create a SOAPException with a detail element.
[WebMethod]
public void
ThrowsSoapExceptionWithDetail()
{
XmlDocument doc = new XmlDocument();
XmlNode detail =
doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
XmlNode custom =
doc.CreateNode(XmlNodeType.Element, "custom", "http://example.com/xml/namespace/blah");
custom.InnerXml = "Detail value";
detail.AppendChild(custom);
throw new SoapException("This is a SOAP exception with a detail element.", SoapException.ServerFaultCode, Context.Request.Url.AbsoluteUri, detail);
}
The SOAP 1.1 response is:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>This is a SOAP exception with a detail element.</faultstring>
<faultactor>http://localhost/simplewebservice/service1.asmx</faultactor>
<detail>
<custom xmlns="http://example.com/xml/namespace/blah">Detail value</custom>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
and the SOAP 1.2 response is:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Receiver</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">This is a SOAP exception with a detail element.</soap:Text>
</soap:Reason>
<soap:Node>http://localhost/simplewebservice/service1.asmx</soap:Node>
<detail>
<custom xmlns="http://example.com/xml/namespace/blah">Detail value</custom>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
The SOAP 1.2 response now has the wrong qualified name for the detail element. It should be <soap:Detail>, but instead is merely <detail>, same as the SOAP 1.1 response.
It seems that the ASP.Net 2.0 framework has done quite a bit to transform a SOAPException into the appropriate form for the SOAP version, but neglected to properly handle the detail element. Additionally, they don't seem to have exposed the correct SOAP 1.2 qualified name for the detail element as was done with the SoapException.DetailElementName property.
So, what is the correct way to add a detail element to a SOAP fault response that works for both SOAP 1.1 and SOAP 1.2? Do I need to detect the SOAP version myself and hard-code the SOAP 1.2 qualified name for the detail element?
No idea about the coding part of your question, sorry, but a workaround wound be to disable the soap1.2 in your web.config, if you haven't already look that way.
....
<webServices>
<protocols>
<remove name="HttpSoap12"/>
</protocols>
</webServices>
The following is not meant to be snide:
The fix to this problem is to use WCF.
This looks like a bug in ASMX web services handling of the detail element in a SOAP 1.2 fault. It obviously makes no sense for the qualified name of the element to change based on whether or not the element has a value.
You could report this error on Connect, but since only critical ASMX bugs are being fixed, that's unlikely to help you.
I doubt that WCF has this problem, since it fully supports SOAP Faults.
This is a late answer, but since I've ran into the issue myself I thought I might as well put my solution here, which is essentially to pass along the version of the SOAP protocol to the method that builds the detail section of the fault message.
The WebService class from which an ASMX web service class is derived exposes the SoapVersion property, which contains the version of the SOAP protocol used to make the current SOAP request.
A detail section appropriate for the current SOAP version can then be built easily.
using System.Xml.Linq;
XNamespace detailElementNamespace;
string detailElementName;
if (soapVersion == SoapProtocolVersion.Soap12)
{
detailElementNamespace = "http://www.w3.org/2003/05/soap-envelope";
detailElementName = "Detail";
}
else
{
detailElementNamespace = "";
detailElementName = "detail";
}
var document = new XmlDocument();
document.LoadXml(
new XElement(detailElementNamespace + detailElementName,
new XElement("MySection",
new XElement("MyCode", "..."),
new XElement("MyDescription", "...")
)).ToString());
throw new SoapException(
"MESSAGE",
SoapException.ClientFaultCode,
"ACTOR",
document.DocumentElement);

How to get my Web Service response XML to validate in Liquid XML Studio?

Web Service code (ASP.NET 2.0):
[WebMethod]
[return: XmlElement("TestMe")]
public string TestMe(int value)
{
return value.ToString();
}
The will result in this response:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<TestMeResponse xmlns="http://example.org/WebServiceTest">
<TestMe>7499</TestMe>
</TestMeResponse>
</soap:Body>
</soap:Envelope>
If I save this as a XML file, open it up in Liquid XML Studio and try to validate it, I get this error message:
Could not find schema information for the element 'http://example.org/WebServiceTest:TestMeResponse'.
Could not find schema information for the element 'http://example.org/WebServiceTest:TestMe'
So how do I add the correct namespace and/or schema for this to validate correctly?
My WSDL ...asmx?WSDL includes the schema definition for the TestMeResponse and TestMe elements, but how do I get this into the response?
You don't put the schema in the response. It's in the WSDL. You'll need to pull the schema (or schemas) out of the WSDL for Liquid XML to see.

Resources