jwagenleitner / groovy-wslite Goto Github PK
View Code? Open in Web Editor NEWLightweight SOAP and REST webservice clients for Groovy
License: Apache License 2.0
Lightweight SOAP and REST webservice clients for Groovy
License: Apache License 2.0
Hi!
I love wslite. I am not trying to connect to a keystone that requires client authentication and when I specify sslKeystoreFile etc and whether or not I send it in on the send() call with a map or use System.setProperty(), I keep getting the following error:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I am using Grails 1.3.7 and running on amazon elastic beanstalk but this error is actually happening on my development machine.
Would you have any ideas about how to fix/where to put the .jks files (preferably somewhere in the war file so I can upload into the EBS and not have to rebuild my site's environment using a custom image.)
THANKS!
Might be useful to be able to set a default SOAP Header on a client. Some services have a login, then in future requests they expect a custom header be sent containing the credentials/token.
def soapClient = new SOAPClient(url:"https://...")
....
soapClient.defaultSOAPHeader(...)
Should provide a switch to turn off sending the header on a request by request basis.
Rather than assume v1.1 when strings are passed to SOAPClient.send()
, the method should auto-detect the soap version based on the namespaceURI of the root element (envelope
). The client can still override using the SOAPClient.send(SOAPVersion, String)
method.
There is documentation on submitting simple data types (strings, booleans, etc) as parameters. What about objects, based on classes with subclasses. Does this need to be broken down into simple data types, all the way down through the hierarchy? If it's possible, what does the syntax look like?
Hi, I'm having some issues calling the Marketo SOAP api. I'm getting an "[Fatal Error] :1:1: Content is not allowed in prolog." error no matter how I format the XML, I have used the MarkupBuilder along with a String format. For other calls to the Marketo API I found that the String format works where using the MarkupBuilder does not. But this could be a issue with how I'm building the XML.
I have tested the call in SoapUI 4.5.1 and it works fine.
I have also tried this in both the Releases and Snapshots
endpoint is "https://na-q.marketo.com/soap/mktows/1_8"
WSDL is the end point address with "?WSDL" at the end.
My Groovy Version is "2.0.1 JVM: 1.6.0_35 Vendor: Apple Inc. OS: Mac OS X"
def response = client.send(
"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mkt="http://www.marketo.com/mktows/">
<soapenv:Header>
<mkt:AuthenticationHeader>
<mktowsUserId>${userID}</mktowsUserId>
<requestSignature>${requestSignature}</requestSignature>
<requestTimestamp>${requestTimestamp}</requestTimestamp>
</mkt:AuthenticationHeader>
</soapenv:Header>
<soapenv:Body>
<mkt:paramsRequestCampaign>
<source>MKTOWS</source>
<leadList>
<leadKey>
<keyType>EMAIL</keyType>
<keyValue>${email}</keyValue>
</leadKey>
</leadList>
<programName>Test Program</programName>
<campaignName>Test Campaign</campaignName>
<programTokenList>
<attrib>
<name>test</name>
<value>9</value>
</attrib>
</programTokenList>
</mkt:paramsRequestCampaign>
</soapenv:Body>
</soapenv:Envelope>"""
)
Any help would be great!
-Thanks!
Using RESTClient().post() throws a RESTContentParseException, when parsing a 200/OK with an empty response body.
service returns a content type of text/xml;charset="utf-8"
, which is causing an UnsupportedEncodingException. The double quotes are not being chopped off in the HTTP.parseCharsetParamFromContentType() method before being passed to the 'new String()' method in HttpResponse.getContentAsString()
Provide a way to inject a logger so we don't have to add a dependency. Need to take a close look at the new Groovy @Log
annotation. Out of the box we should probably default to a null logger and provide a stdout logger, but allow user to inject their own logger.
In the src I see all requests are generated on memory and not saved in SOAPClient fields, but for debug purposer sometimes you need to see the raw request and response.
I would suggest to add these fields so one can inspect them after the .send() to check for problems.
What do you think?
Thanks for this great tool!
See http://nexus.sonatype.org/oss-repository-hosting.html
Once in central need to document how the library can be included as a dependency using maven/gradle and include example of how to use with @Grab
.
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.5.2')
import wslite.rest.*
try {
def client = new RESTClient("https://www.google.com/")
client.httpClient.sslTrustStoreFile = "c:/temp/keystore_that_does_not_exist.jks"
def response = client.get()
} catch (ex) {
println ex
}
This returns wslite.rest.RESTClientException: Cannot invoke method disconnect() on null object
.
WS which are session-based (multi-operation with connect first and without token) are not handled by this library
If the HTTP library handled cookies, that would enable users using this kind of WS
EX : I have to connect to a SOAP webservice which has a Connect method which is to call first
subsequent calls to other operations trigger SOAPFault : "you are not connected"
See http://groovy.329449.n5.nabble.com/Groovy-WSLite-SOAP-Request-Issue-Urgent-tp5710008.html.
I am using Groovy-WSLite 0.7.0 to send a soap request. However when I invoke client.send method regardless the args that I used in this method, it always returned the following error.
wslite.soap.SOAPClientException: 200 OK -- 200 OK -- 200 OK -- No such property: bytes for class: sun.net.www.http.PosterOutputStream
I used the following code.
def client = new SOAPClient('http://rvwpremapp01:8080/arsys/WSDL/public/rvwpremapp01/HPD_IncidentInterface_Create_WS_App')
def response=client.send("""<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:urn='urn:HPD_IncidentInterface_Create_WS_App'><soapenv:Header><urn:AuthenticationInfo><urn:userName>Allen1</urn:userName>
<urn:password></urn:password></urn:AuthenticationInfo></soapenv:Header><soapenv:Body><urn:HelpDesk_Submit_Service>
<urn:First_Name>test</urn:First_Name><urn:Impact>1-Extensive/Widespread</urn:Impact><urn:Last_Name>user1</urn:Last_Name>
<urn:Reported_Source>Other</urn:Reported_Source><urn:Service_Type>User Service Request</urn:Service_Type><urn:Status>New</urn:Status>
<urn:Action>Further Investigation</urn:Action><urn:Summary>Test</urn:Summary>
<urn:Urgency>1-Critical</urn:Urgency><urn:Work_Info_Date>2012-05-
31T13:00:00</urn:Work_Info_Date></urn:HelpDesk_Submit_Service></soapenv:Body></soapenv:Envelope>""")
Also if I tried to use
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.7.0')
import wslite.soap.*
I got the below error, but if I comment out '@Grab...', it works fine on this part, but still can't send request.
unexpected token: import @ line 7, column 1.
import wslite.soap.*
^
1 error
I only put the Groovy-WSLite jar file into the lib folder for this deployment, not sure if there is anything else that I need to install to make it work.
Need to document all the options for both the SOAP and REST clients.
I'm trying to do a post to a service, and I have to pass both parameters and a file attachement. I'm having a hard time seeing how to do that. Is that possible?
I'm using the REST portion of the API.
For example when I try to create the following service, the tags within body and head are not rendered.
...
def soapClient
def sendSms(args) {
def response = soapClient.send(
SOAPAction: 'urn:servicioFrontera#ejecutar',
connectTimeout:5000,
readTimeout:10000,
useCaches:false,
followRedirects:false,
sslTrustAllCerts:true ) {
version SOAPVersion.V1_1 // SOAPVersion.V1_1 is default
soapNamespacePrefix "SOAP" // "soap-env" is default
encoding "ISO-8859-1" // "UTF-8" is default encoding for xml
body {
ejecutar( 'xmlns:mns':'urn:servicioFrontera') {
xmlOrder(){
order{
header{
}
body{
}
}
}
}
}
}
}
...
...
Thank you.
I want to call a SOAP WebService that returns the response in format multipart/related.
This results in a SOAPMessageParseException telling me that "Content Is Not Allowed In Prolog".
I had a look at the sources of SOAPClient.groovy and think this is maybe because it just calls:
String soapMessageText = httpResponse.contentAsString
def soapEnvelope = parseEnvelope(soapMessageText)
getContentAsString() seems to return the raw HTTP body.
I can't find a forum or anything for discussing usage, so I'll start here. If there is a better place to post this, please close it and redirect me to the right place.
I have an application where I am using wslite to make a connection from my application to a backend web services enabled application. The default 2 connections per host is a huge bottleneck for me and I am looking to change it.
All of the examples I have seen show setting the maxTotal and maxPerRoute settings on the connection manager and then assigning that to the httpClient.
I believe I can instantiate my own httpClient and tell wslite to use it, but is there any simple way to change those properties with the default SoapClient definition?
Thanks for the help!
To enable better error reporting and facilitate client logging, HTTPClientException should provide access to the HTTPRequest/HTTPResponse.
So I recently came across your package and have found using it to GET XML content. Now I am starting to test out the POST and can not get past this basic post function. Any ideas on what I might be doing incorrectly? Currently I am using version 0.5.2.
String post(String myXML) throws Exception {
def client
println this.url + this.path2
println myXML
try {
client = new RESTClient(this.url + this.path2)
client.authorization = new HTTPBasicAuthorization(this.username, this.password)
def response = client.post() {
text myXML
}
return response.contentAsString
} catch (Exception e) {
println e.message
return null
}
}
When I attempt to run this I get
No signature of method: wslite.rest.RESTClient.post() is applicable for argument types: (Moodle.SchoolInfo$_post_closure1) values: [Moodle.SchoolInfo$_post_closure1@7846a55e]
Possible solutions: post(groovy.lang.Closure), post(java.util.Map, groovy.lang.Closure), put(groovy.lang.Closure), wait(), get(), wait(long)
null
RESTClient should provide default settings for accept and content-type (for request). If these header values are not provided in the request these defaults should be applied.
There should also be a default for charset that will effect string to byte conversions.
Add support to send json requests and automatically parse json responses.
SOAP messages are encoded to bytes using the system default encoding. This is causing issues for systems that do not have their encoding set to UTF-8. Currently, the Content-Type header charset is harded to UTF-8. Need to allow for handling character encodings when encoding
is specified in the closure or if the user passed a Content-Type header with a charset parameter.
Following the basic instructions from the README, I am unable to build groovy-wslite's jar file.
Here's the brief version of the error message:
FAILURE: Build failed with an exception.
* Where:
Build file '/tmp/groovy-wslite/build.gradle' line: 46
* What went wrong:
A problem occurred evaluating root project 'groovy-wslite'.
Cause: Could not find property 'pgpSecretKeyRingFile' on
root project 'groovy-wslite'.
I've posted detailed output (from running gradle jar --info --debug --stacktrace
) to this gist.
SOAPMessageParseException
exceptions that are generated in SOAPClient#parseEnvelope
should contain the SOAP message text.
Replicating code:
import wslite.soap.SOAPClient
SOAPClient soapClient = new SOAPClient('http://localhost')
println soapClient.send() {}
Result:
Sending request...
Caught: java.lang.StackOverflowError
at wslite.http.HTTPHeaderMap.getKeyIgnoreCase(HTTPHeaderMap.groovy:44)
at wslite.http.HTTPHeaderMap.this$5$getKeyIgnoreCase(HTTPHeaderMap.groovy)
at wslite.http.HTTPHeaderMap.put(HTTPHeaderMap.groovy:26)
at wslite.http.HTTPHeaderMap.put(HTTPHeaderMap.groovy:30)
at wslite.http.HTTPHeaderMap.put(HTTPHeaderMap.groovy:30)
...
at wslite.http.HTTPHeaderMap.put(HTTPHeaderMap.groovy:30)
at wslite.http.HTTPHeaderMap.put(HTTPHeaderMap.groovy:30)
at wslite.http.HTTPHeaderMap.setProperty(HTTPHeaderMap.groovy)
at wslite.soap.SOAPClient.setContentTypeHeaderIfNotPresent(SOAPClient.groovy:144)
at wslite.soap.SOAPClient.this$2$setContentTypeHeaderIfNotPresent(SOAPClient.groovy)
at wslite.soap.SOAPClient.buildHTTPRequest(SOAPClient.groovy:76)
at wslite.soap.SOAPClient.this$2$buildHTTPRequest(SOAPClient.groovy)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:56)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:44)
at wslite.soap.SOAPClient.send(SOAPClient.groovy)
at test.run(test.groovy:5)
Is not a problem with Sun JVM (cannot be used on AIX of course) or if run from the Groovy source instead of the jar distribution.
I must confess to be using Groovy 1.7.5 since that is what is packaged with Grails 1.3.5. Does it really require Groovy 1.7.6 or better and could that be the problem? If so that means groovy-wslite can only be used with the latest version of Grails (1.3.7), doesn't it?
The home page examples have a minor problem with the proxy explanation.
First, there should be another closing parenthesis on the proxy line:
def proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress('proxy.example.com', 8080)
Should be:
def proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress('proxy.example.com', 8080))
In addition, this will not work if the proxy requires authentication, which is very poorly documented for the Java platform in general, so it would probably be a good idea to add the following:
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new
PasswordAuthentication("username","password".toCharArray());
}})
Repository does not contain config/checkstyle/checkstyle.xml.
When trying to create a simple soap based webservice using grails following the
Mother's day example as shown, I recieve a IncompatibleClassChangeError as shown:
Stacktrace follows:
org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [failoverServer] of controller [net.sococo.serverconfig.FailoverServerController] caused exception: java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.Exception do not match. Expected 4 but got 5
at java.lang.Thread.run(Thread.java:722)
Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.Exception do not match. Expected 4 but got 5
... 1 more
Caused by: java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.Exception do not match. Expected 4 but got 5
at wslite.http.HTTPClientException.(HTTPClientException.groovy:29)
at wslite.soap.SOAPClientException.(SOAPClientException.groovy:28)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:61)
at wslite.soap.SOAPClient$send$0.callCurrent(Unknown Source)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:48)
at wslite.soap.SOAPClient.send(SOAPClient.groovy)
at wslite.soap.SOAPClient$send.call(Unknown Source)
at net.sococo.serverconfig.FailoverServerController$_closure1.doCall(FailoverServerController.groovy:21)
at net.sococo.serverconfig.FailoverServerController$_closure1.doCall(FailoverServerController.groovy)
I wasnt sure where else to post this, please help with this issue that is occuring.
david
I'm using the JSON-java library for JSON parsing and have modified it in order to provide a Map interface to JSONObject and List interface to JSONArray. Instead of modifying the code directly it should be wrapped with wrapper classes that implement the correct interface to make updating to the latest lib version easier.
[Fatal Error] :-1:-1: Premature end of file.
17:13:12.858 [pool-1-thread-1] ERROR c.r.i.fileService.GroovyFileService - Unrecoverable error occured whilst trying to upload file to cloud files!
wslite.rest.RESTContentParseException: Premature end of file.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0_32]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) ~[na:1.6.0_32]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) ~[na:1.6.0_32]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_32]
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) ~[groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) ~[groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:202) [groovy-all-1.8.5.jar:1.8.5]
at wslite.rest.RESTClient.buildResponse(RESTClient.groovy:101) ~[groovy-wslite-0.7.0.jar:na]
at wslite.rest.RESTClient.this$2$buildResponse(RESTClient.groovy) ~[groovy-wslite-0.7.0.jar:na]
at wslite.rest.RESTClient$this$2$buildResponse.callCurrent(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145) [groovy-all-1.8.5.jar:1.8.5]
at wslite.rest.RESTClient.executeMethod(RESTClient.groovy:83) ~[groovy-wslite-0.7.0.jar:na]
at wslite.rest.RESTClient.this$2$executeMethod(RESTClient.groovy) ~[groovy-wslite-0.7.0.jar:na]
at wslite.rest.RESTClient$this$2$executeMethod$0.callCurrent(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149) [groovy-all-1.8.5.jar:1.8.5]
at wslite.rest.RESTClient.executeMethod(RESTClient.groovy:61) ~[groovy-wslite-0.7.0.jar:na]
at wslite.rest.RESTClient.this$2$executeMethod(RESTClient.groovy) ~[groovy-wslite-0.7.0.jar:na]
at wslite.rest.RESTClient$this$2$executeMethod.callCurrent(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145) [groovy-all-1.8.5.jar:1.8.5]
at wslite.rest.RESTClient.get(RESTClient.groovy:45) ~[groovy-wslite-0.7.0.jar:na]
at wslite.rest.RESTClient$get.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) [groovy-all-1.8.5.jar:1.8.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) [groovy-all-1.8.5.jar:1.8.5]
The code doesn't check to see if there is any content and so the XMLSlurper logic in the ResponseBuilder object dies a horrible death. Checking to see if there's any content at all would be a good first bet.
Hi, I am writing a Grails application to access a SOAP web service and made the decision
to use groovy-wslite. I have been able to use groovy and get this to work, however I have
had nothing but problems trying to integrate this into my grails app.
I am using Grails 2.1.0, groovy-wslite:0.7.1, java 1.6
Here is what I have done:
Now this works in the groovy console perfectly fine. I tried adding the runtime dependency to
the BuildConfig.groovy file. Didn't help.
Any ideas would be really helpful!!
Hello,
SOAP requests are missing first line, e.g.
POST: https://myhost/ws/person HTTP/1.1
This is invalid HTTP so server returns HTTP 400.
Workaround: add it as defaultHeader:
def httpClient = new HTTPClient();
httpClient.defaultHeaders = [POST:'https://myhost/ws/person HTTP/1.1']
def soapClient = new SOAPClient("https://myhost/ws/person", httpClient)
This may not be an issue with wslite but instead my lack of familiarity.
I'm working with a SSL-guarded web service. For the method, it demands an appropriate namespace.. There is documentation for that. For the parameters, it demands an empty string xmlns. Without it, the method fails. Using wslite syntax, is it possible to make this call...or do I have to feed raw xml?
When post'ing JSON data, looks like the builder only allows String values.
The following fails with a StackOverflowException
def value = "a"
client.post() {
json param: value
}
The following works:
def value = "a"
client.post() {
json param: value.toString()
}
The following is code from the SOAPClient. The SOAPResponse should have methods to make this type of access easier.
if (!soapResponse.Envelope.Body.Fault.isEmpty()) {
def soapFault = buildSOAPFaultException(soapResponse.Envelope.Body.Fault)
A good start would be:
boolean hasFault()
GPathResult getFault()
GPathResult getHeader()
GPathResult getBody()
The current HTTPConnectionFactory
class is pretty ugly, needs rework before releasing 1.0.0.
Make the handling of HTTP request/response headers more consistent. Retrieving headers should be case-insensitive, setting should preserve case.
Good reference is how they are handled by Rack::Utils::HeaderHash
, see
The EU has changed its WSDL to a new address but now I am getting a 'wslite.soap.SOAPMessageParseException: Root element is definitions, expected Envelope
' error message but am unable to see how to rectify this...
proxy = new SOAPClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
rate = proxy.send(SOAPAction:'http://ec.europa.eu/taxation_customs/vies/checkVatService'){
body('xmlns':'urn:ec.europa.eu:taxud:vies:services:checkVat:types'){
checkVat{
countryCode(cc)
vatNumber(vv)
}
}
}
Any pointers??
SOAPClient#buildHTTPRequest
modifies (removes) values passed in the params map to SOAPClient#send
. The key SOAPAction
is being removed and this would cause problems for callee's that want to reuse the params.
See RESTClient where we make a defensive copy first.
Here's a test case to show the problem:
@GrabResolver(name='groovy-wslite', root='https://oss.sonatype.org/content/groups/public', m2Compatible=true)
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.2-SNAPSHOT', changing=true)
import wslite.soap.*
def myParams = [SOAPAction:'http://www.27seconds.com/Holidays/US/Dates/GetMartinLutherKingDay',
connectTimeout: 20000]
println "myParams before: ${myParams}"
def soapClient = new SOAPClient('http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx')
def resp = soapClient.send(myParams) {
body {
GetMartinLutherKingDay('xmlns':'http://www.27seconds.com/Holidays/US/Dates/') {
year(2011)
}
}
}
println "myParams after: ${myParams}"
assert "2011-01-15T00:00:00" == resp.GetMartinLutherKingDayResponse.GetMartinLutherKingDayResult.text()
assert 200 == resp.httpResponse.statusCode
assert myParams.SOAPAction == 'http://www.27seconds.com/Holidays/US/Dates/GetMartinLutherKingDay'
println "done"
[Fatal Error] :1:1: Premature end of file.
Caught: wslite.soap.SOAPMessageParseException: Premature end of file.
wslite.soap.SOAPMessageParseException: Premature end of file.
at wslite.soap.SOAPClient.buildSOAPResponse(SOAPClient.groovy:92)
at wslite.soap.SOAPClient.this$2$buildSOAPResponse(SOAPClient.groovy)
at wslite.soap.SOAPClient$this$2$buildSOAPResponse.callCurrent(Unknown Source)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:63)
at wslite.soap.SOAPClient$send$0.callCurrent(Unknown Source)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:44)
at wslite.soap.SOAPClient.send(SOAPClient.groovy)
at wslite.soap.SOAPClient$send.call(Unknown Source)
at au.com.optus.mcas.ws.client.email.SendEmail.run(SendEmail.groovy:43)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at wslite.soap.SOAPClient.parseEnvelope(SOAPClient.groovy:98)
at wslite.soap.SOAPClient.this$2$parseEnvelope(SOAPClient.groovy)
at wslite.soap.SOAPClient$this$2$parseEnvelope.callCurrent(Unknown Source)
at wslite.soap.SOAPClient.buildSOAPResponse(SOAPClient.groovy:86)
The call to the webservice does take place and completes successful but the SOAP client tries to read a response regardless.
I have uploaded a standalone test harness that can be used to troubleshoot this issue to the following location:
https://www.box.com/s/e31499a522cc8d78a05f
When converting strings for the HTTP request need to look for a charset param or parse charset from the content-type.
SOAPClient is not generating a SOAPFaultException and is instead returning an HTTPClientException. Also need to ensure both SOAP 1.1 and 1.2 faults are handled correctly since the structure is different between the two versions.
See http://groovy.329449.n5.nabble.com/groovy-wslite-fault-handling-td4774424.html
The wslite.http.HTTPHeaderMap
class can be replaced by a case insensitive TreeMap.
Hi.
I am trying to talk to a web service that insists on having SOAPAction header set.. when i invoke via SOAPui i see this
header value:
SOAPAction:
with soap UI there is no value for the header, but the header is there nonetheless.
I wanted to replicate this by sending raw xml to the web svc via ws lite. I used the version of SOAPClient.send() that takes a parameter map and a blob of raw XML for the soap input msg... like this >
def response = client.send( [SOAPAction: '' ], xmlRequest )
However, i ran into what seems like a bug in SOAPClient.setSoapActionHeaderIfNotPresent () -- This
method treats the empty string same as null, And the result is no SOAPAction header gets sent when an invocation is made.
This causes the server i am communicating to choke and send me back an error response.
I needed to send the header so I modified the method as shown below. I'm sorry I don't have time to create a full patch, but I'm hoping the fix I am suggesting will make it into your code base some how. Thanks in advance - Chris
the fix <<<<
private void setSoapActionHeaderIfNotPresent(HTTPRequest httpRequest, SOAPVersion soapVersion, String soapAction) {
// if (!soapAction) { // <<<< --- i changed this .. to the line below
if (soapAction == null) {
return
}
if (soapVersion == SOAPVersion.V1_1) {
if (!httpRequest.headers[SOAP.SOAP_ACTION_HEADER]) {
httpRequest.headers[SOAP.SOAP_ACTION_HEADER] = soapAction
}
} else if (soapVersion == SOAPVersion.V1_2) {
httpRequest.headers[HTTP.CONTENT_TYPE_HEADER] += '; ' + SOAP.SOAP_ACTION_V12_HEADER + '="' + soapAction + '"'
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.