Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #449 (closed defect: fixed)

Opened 1 year ago

Last modified 9 months ago

missing xsi:type

Reported by: user Assigned to: nahi
Priority: high Milestone: 1.5.9
Component: soap4r Version: 1.5
Keywords: Cc:

Description (Last modified by nahi)

I created with swdl2ruby a defaultDriver that is working it posts to the soap server and gets a response: However it says the authInfo object is not valid probably missing xsi:type. Also the namespaces are different.... How to fix this properly ???

using ruby 1.8.5 and soap4r 1.5.8 (in core not as gem)

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tms="[#####]" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <env:Body>
    <getBouncesByMailing>
      <authInfo>
        <organization>[#####]</organization>
        <password>[#####]</password>
        <username>[#####]</username>
      </authInfo>
      <mailing>[#####]</mailing>
      <from>[#####]</from>
      <to>[#####]</to>
    </getBouncesByMailing>
  </env:Body>
</env:Envelope>

This is what does work (created with perl)

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tms="[#####]" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <tms:getBouncesByMailing>
      <authInfo xsi:type="impl:AuthInfo">
        <organization xsi:type="xsd:string">[#####]</organization>
        <password xsi:type="xsd:string">[#####]</password>
        <username xsi:type="xsd:string">[#####]</username>
      </authInfo>
      <mailing xsi:type="xsd:string">[#####]</mailing>
      <from xsi:type="xsd:dateTime">[#####]</from>
      <to xsi:type="xsd:dateTime">[#####]</to>
    </tms:getBouncesByMailing>
  </soap:Body>
</soap:Envelope>

Attachments

generate_explicit_type.diff (4.5 kB) - added by nahi on 11/02/07 12:15:58.
patch for controlling explicit typing for literal service

Change History

11/01/07 04:24:48 changed by user

  • type changed from defect to enhancement.
  • component changed from wsdl4r to soap4r.

I have fixed a whole buch of problems the solution is not that great and I am searching of a better way to do this. For now this is the solution I found


#!/usr/bin/env ruby

require 'rubygems' require 'defaultDriver.rb'

obj = TMService.new() obj.generate_explicit_type = true obj.wiredump_dev = STDERR

ele = SOAP::SOAPElement.new("tms:getSubscriber") ele0 = SOAP::SOAPElement.new("authInfo") ele0.extraattrxsi:type? = "impl:AuthInfo"

ele1 = SOAP::SOAPElement.new("organization") ele1.extraattrxsi:type? = "xsd:string" ele1.text = "#####" ele2 = SOAP::SOAPElement.new("password") ele2.extraattrxsi:type? = "xsd:string" ele2.text = "#####" ele3 = SOAP::SOAPElement.new("username") ele3.extraattrxsi:type? = "xsd:string" ele3.text = "#####"

ele4 = SOAP::SOAPElement.new("databaseId") ele4.extraattrxsi:type? = "xsd:string" ele4.text = "Plb" ele5 = SOAP::SOAPElement.new("uid") ele5.extraattrxsi:type? = "xsd:string" ele5.text = "crap" ele6 = SOAP::SOAPElement.new("email") ele6.extraattrxsi:type? = "xsd:string" ele6.text = "daniel@2organize.com"

ele0.add(ele1) ele0.add(ele2) ele0.add(ele3) ele.add(ele0) ele.add(ele4) ele.add(ele5) ele.add(ele6)

response = obj.getSubscriber(ele)


The only thin I have left to do is adding some namespaces which ain't that difficult and change the env:Envelope and env:Body to soap:Envelope and soap:Body

Any ideas ???

11/01/07 20:08:52 changed by user

did it as well it ain't pretty but it works:

require 'soap/rpc/driver'
require 'soap/header/handler'

class DefaultNSFilter < SOAP::Filter::Handler
  def on_outbound(envelope, opt)
    opt[:default_ns] = @default_ns
    envelope
  end

  def initialize
    @default_ns = SOAP::NS.new
    @default_ns.assign(SOAP::EnvelopeNamespace,"soap")
    @default_ns.assign('http://wstest._2organize.nl','tms')
    @default_ns.assign('http://schemas.xmlsoap.org/soap/encoding/','soapenc')
    @default_ns.assign('http://www.w3.org/2001/XMLSchema','xsd')
  end
end

obj = TMService.new()
obj.generate_explicit_type = true
obj.filterchain << DefaultNSFilter.new

11/01/07 23:29:32 changed by nahi

  • priority changed from normal to high.
  • type changed from enhancement to defect.
  • description changed.
  • milestone set to 1.5.9.

Hi,

Hmm. Your server seems to require explicitly typed request for doc/lit service. Unfortunately, soap4r ignores generate_explicit_type for literal service now. I'm looking for the way to enable this option for literal service as well but it seems to require rather big change... Please wait for a while.

11/02/07 12:15:58 changed by nahi

  • attachment generate_explicit_type.diff added.

patch for controlling explicit typing for literal service

11/02/07 12:19:13 changed by nahi

Hi again,

Would you please try this patch at http://dev.ctor.org/soap4r/attachment/ticket/449/generate_explicit_type.diff?format=raw ?

This patch enables Driver#generate_explicit_type for literal service. With this patch, the following script generates typed XML as a request.

  wsdl="TMService.wsdl"
  veritate = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
  veritate.wiredump_dev = STDOUT
  veritate.generate_explicit_type = true
  veritate.test_loopback_response << ''
  request = {
    :authInfo => {
      :organization=>"[#####]",
      :username=>"[#####]",
      :password=>"[#####]"
    },
    :databaseId=>"PlB",
    :uid=>"test",
    :email=>"[#####]"
  }
  result = veritate.getSubscriber(request)
  p result

Sample request;

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <n1:getSubscriber xmlns:n1="http://tmservice.services.axis.tripolis.com">
      <n1:authInfo xsi:type="n1:AuthInfo">
        <n1:organization xsi:type="xsd:string">[#####]</n1:organization>
        <n1:username xsi:type="xsd:string">[#####]</n1:username>
        <n1:password xsi:type="xsd:string">[#####]</n1:password>
      </n1:authInfo>
      <n1:databaseId xsi:type="xsd:string">PlB</n1:databaseId>
      <n1:uid xsi:type="xsd:string">test</n1:uid>
      <n1:email xsi:type="xsd:string">[#####]</n1:email>
    </n1:getSubscriber>
  </env:Body>
</env:Envelope>

I'll incorporate it in soap4r-1.5.9 if it works.

Regards, // NaHi

11/02/07 22:58:37 changed by user

It is working.. The server excepts this.. however don't know if this is something to fix or not but Authinfo is of xsi:type="impl:AuthInfo"

Thanks a bunch

02/10/08 10:48:24 changed by nahi

  • status changed from new to closed.
  • resolution set to fixed.

(In [2008]) * enabled Sriver#generate_explicit_type for literal services. closes #449.