Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Groovy:在不使用wsdl的情况下从信封创建和发送SOAP请求(如curl)。_Curl_Soap_Groovy_Wsdl - Fatal编程技术网

Groovy:在不使用wsdl的情况下从信封创建和发送SOAP请求(如curl)。

Groovy:在不使用wsdl的情况下从信封创建和发送SOAP请求(如curl)。,curl,soap,groovy,wsdl,Curl,Soap,Groovy,Wsdl,我有大量从数据库中提取的xml字符串,我希望将它们包装成SOAP消息并发送给收件人。我想使用groovy脚本来实现这一点,就像使用curl一样。这意味着我希望避免使用wsdl,而是将现有xml字符串体包装到soap信封中,然后将其发送到收件人的地址和端口。是否有任何方法可以使用wslite或任何其他用于groovy的SOAP api实现此目的?您可以使用HttpBuilder: HTTPBuilder http = new HTTPBuilder( 'http://some.com' ) htt

我有大量从数据库中提取的xml字符串,我希望将它们包装成SOAP消息并发送给收件人。我想使用groovy脚本来实现这一点,就像使用curl一样。这意味着我希望避免使用wsdl,而是将现有xml字符串体包装到soap信封中,然后将其发送到收件人的地址和端口。是否有任何方法可以使用wslite或任何其他用于groovy的SOAP api实现此目的?

您可以使用
HttpBuilder

HTTPBuilder http = new HTTPBuilder( 'http://some.com' )
http.request( POST ){
  uri.path = '/somepath'
  requestContentType = URLENC
  body = [ your:json, envelope:here ]
  headers.Accept = 'application/json'

  response.success = { resp, json ->
    println json
  } 
}
或普通的
UrlConnection

HttpURLConnection connection = new URL( 'http://some.com/somepath' ).openConnection()
connection.requestMethod = 'POST'
connection.doOutput = true
connection.outputStream.withWriter{ it << "{ some:value }" } // here comes your envelop
connection.connect()
String result
connection.content.withReader{ result = new JsonSlurper().parseText( it.readLine() ).someKey }
log.info "got result $result"
HttpURLConnection=newurl('http://some.com/somepath”).openConnection()
connection.requestMethod='POST'
connection.doOutput=true

connection.outputStream.withWriter{it您可以使用
HttpBuilder

HTTPBuilder http = new HTTPBuilder( 'http://some.com' )
http.request( POST ){
  uri.path = '/somepath'
  requestContentType = URLENC
  body = [ your:json, envelope:here ]
  headers.Accept = 'application/json'

  response.success = { resp, json ->
    println json
  } 
}
或普通的
UrlConnection

HttpURLConnection connection = new URL( 'http://some.com/somepath' ).openConnection()
connection.requestMethod = 'POST'
connection.doOutput = true
connection.outputStream.withWriter{ it << "{ some:value }" } // here comes your envelop
connection.connect()
String result
connection.content.withReader{ result = new JsonSlurper().parseText( it.readLine() ).someKey }
log.info "got result $result"
HttpURLConnection=newurl('http://some.com/somepath”).openConnection()
connection.requestMethod='POST'
connection.doOutput=true

connection.outputStream.withWriter{it-Hmm如果我有一个xml代码体而不是json,这是一样的吗?对于客户端部分,这并不重要。如果我有一个xml代码体而不是json,这是一样的吗?对于客户端部分,这并不重要