如何访问grails中的wsdl - 返回400状态代码

时间:2014-03-18 05:40:56

标签: java web-services grails soap wsdl

我想将数据发送到person对象。如何使用PostMethod。

    def payload ='<person><nationalId>'+1234567+'</nationalId></person>'
    def method = new PostMethod(url)
    def client = new HttpClient()
    payload = payload.trim()
    method.addRequestHeader("Content-Type","text/xml")
    method.addRequestHeader("Accept","text/xml,application/xml;q=0.9")

    Credentials credentials = new UsernamePasswordCredentials('simple', 'simple');
    client.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST,8080, AuthScope.ANY_REALM, "digest"),credentials);

    method.setRequestEntity(new StringRequestEntity(payload))
    def statusCode = client.executeMethod(method)
    println "STATUS CODE : ${statusCode}"
    def resultsString = method.getResponseBodyAsString()
    method.releaseConnection()
    println resultsString

我尝试了以上编码。如何设置密码,用户名和密码摘要。为此,我认为状态代码400即将到来。请通知我犯错的地方

1 个答案:

答案 0 :(得分:0)

尝试查看REST Client Builder Plugin。查看文档,我想,您会找到更方便的发送请求的方式