Soap::RPC::Driver Question


W

Wes Shaddix

------=_NextPart_000_0097_01C5DAFD.70A352E0
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: 7bit

How do you make the soap client send utf-8 encoded instead of ascii encoded
requests?



How do you keep the request serialization from including the data type of
each element?



For example, from a .net client, a working request looks like this



<?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>

- <ContactSave xmlns="http://inovaware.com/prism/">

- <contact>

<ContactKey xsi:nil="true" />

<ContactID />

<NamePrefix />

<NameTitle />

<FirstName>WesTest</FirstName>

<LastName>ShaddixTest</LastName>

<NameSuffix />

<Pronunciation />

<JobTitle />

<Company />

<AddressLine1 />

<AddressLine2 />

<City />

<MailRegion />

<MailCode />

<Country />

<WorkNumber />

<FAXNumber />

<HomeNumber />

<MobileNumber />

<PagerNumber />

<EMailAddress />

<BirthDate xsi:nil="true" />

<Login />

<Password />

<ModifyCount>0</ModifyCount>

</contact>

</ContactSave>

</soap:Body>

</soap:Envelope>



The same code in ruby generates a request (which fails) like this

<?xml version="1.0" encoding="us-ascii" ?>

- <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:ContactSave xmlns:n1="http://inovaware.com/prism/"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

- <contact xsi:type="xsd:anyType">

<ContactKey xsi:nil="true" />

<ContactID xsi:type="xsd:anyType" />

<NamePrefix xsi:type="xsd:anyType" />

<NameTitle xsi:type="xsd:anyType" />

<FirstName xsi:type="xsd:string">WesTestFromRuby</FirstName>

<LastName xsi:type="xsd:string">ShaddixTestFromRuby</LastName>

<NameSuffix xsi:type="xsd:anyType" />

<Pronunciation xsi:type="xsd:anyType" />

<JobTitle xsi:type="xsd:anyType" />

<Company xsi:type="xsd:anyType" />

<AddressLine1 xsi:type="xsd:anyType" />

<AddressLine2 xsi:type="xsd:anyType" />

<City xsi:type="xsd:anyType" />

<MailRegion xsi:type="xsd:anyType" />

<MailCode xsi:type="xsd:anyType" />

<Country xsi:type="xsd:anyType" />

<WorkNumber xsi:type="xsd:anyType" />

<FAXNumber xsi:type="xsd:anyType" />

<HomeNumber xsi:type="xsd:anyType" />

<MobileNumber xsi:type="xsd:anyType" />

<PagerNumber xsi:type="xsd:anyType" />

<EMailAddress xsi:type="xsd:anyType" />

<BirthDate xsi:nil="true" />

<Login xsi:type="xsd:anyType" />

<Password xsi:type="xsd:anyType" />

<ModifyCount xsi:type="xsd:string">0</ModifyCount>

</contact>

</n1:ContactSave>

</env:Body>

</env:Envelope>



Any help is most appreciated.


------=_NextPart_000_0097_01C5DAFD.70A352E0--
 
Ad

Advertisements

N

NAKAMURA, Hiroshi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Wes said:
How do you make the soap client send utf-8 encoded instead of ascii encoded
requests?

Set $KCODE = 'UTF8' if you don't have iconv or uconv been installed.
Soap4r should detect iconv and uconv and use utf-8 by itself.

i.e.
$KCODE = 'UTF8'
drv = ...
or
ruby -Ku myclient.rb
How do you keep the request serialization from including the data type of
each element?

Please set Driver#generate_explicit_type = false.

i.e.

drv = SOAP::RPC::Driver.new(...)
drv.add_method('my_method', ...)
drv.generate_explicit_type = false
drv.my_method(...)

Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDYXN5f6b33ts2dPkRApKxAKDAV0ZOIgb08lXsBYdYB9r6rfzKLwCfcM66
i0f7rTV9iZwGq3rzTFuNkWY=
=gLgO
-----END PGP SIGNATURE-----
 
W

Wes Shaddix

What is iconv and uconv? Also $KCODE = 'UTF8' before creating the soap
client didn't change the encoding to UTF-8, it is still us-ascii

Also, more importantly, how can I change the namespaces that ruby uses to
define the soap envelope and body? I need it to change the namespace name
from 'env' to 'soap'

Thanks so much for helping out. I'm getting really close to getting this to
work which will allow me to introduce ruby as a viable language for our
company.



-----Original Message-----
From: NAKAMURA, Hiroshi [mailto:[email protected]]
Sent: Thursday, October 27, 2005 8:41 PM
To: ruby-talk ML
Subject: Re: Soap::RPC::Driver Question

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Wes said:
How do you make the soap client send utf-8 encoded instead of ascii encoded
requests?

Set $KCODE = 'UTF8' if you don't have iconv or uconv been installed.
Soap4r should detect iconv and uconv and use utf-8 by itself.

i.e.
$KCODE = 'UTF8'
drv = ...
or
ruby -Ku myclient.rb
How do you keep the request serialization from including the data type of
each element?

Please set Driver#generate_explicit_type = false.

i.e.

drv = SOAP::RPC::Driver.new(...)
drv.add_method('my_method', ...)
drv.generate_explicit_type = false
drv.my_method(...)

Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDYXN5f6b33ts2dPkRApKxAKDAV0ZOIgb08lXsBYdYB9r6rfzKLwCfcM66
i0f7rTV9iZwGq3rzTFuNkWY=
=gLgO
-----END PGP SIGNATURE-----
 
W

Wes Shaddix

Update:: I've got most everything correct now, I just have to figure out how
to control the namespace names. Here is my current code :

require 'soap/rpc/driver'

class CustomerController
ENDPOINT = "http://localhost:8080/PrismWebService/PrismAPI.asmx"
NAMESPACE = "http://inovaware.com/prism/"

def save_customer

$KCODE = 'UTF-8'

soapProxy = SOAP::RPC::Driver.new(ENDPOINT, NAMESPACE)

# don't include the datatype with the request
soapProxy.generate_explicit_type = false

# add the mothods and their SOAPAction and their arguments
soapProxy.add_method_with_soapaction('ContactNew', NAMESPACE
+ 'ContactNew')
soapProxy.add_method_with_soapaction('ContactSave',
NAMESPACE + 'ContactSave', 'contact')

# soapProxy.wiredump_dev = STDERR

contact = soapProxy.ContactNew
contact.firstName = "WesTestFromRuby"
contact.lastName = "ShaddixTestFromRuby"
contactKey = soapProxy.ContactSave(contact)
puts(contactKey)
end
end

c = CustomerController.new
c.save_customer

Here is the soap request that is failing::
<?xml version="1.0" encoding="utf-8" ?>
- <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <env:Body>
- <n1:ContactSave xmlns:n1="http://inovaware.com/prism/">
- <contact>
<ContactKey xsi:nil="true" />
<ContactID />
<NamePrefix />
<NameTitle />
<FirstName>WesTestFromRuby</FirstName>
<LastName>ShaddixTestFromRuby</LastName>
<NameSuffix />
<Pronunciation />
<JobTitle />
<Company />
<AddressLine1 />
<AddressLine2 />
<City />
<MailRegion />
<MailCode />
<Country />
<WorkNumber />
<FAXNumber />
<HomeNumber />
<MobileNumber />
<PagerNumber />
<EMailAddress />
<BirthDate xsi:nil="true" />
<Login />
<Password />
<ModifyCount>0</ModifyCount>
</contact>
</n1:ContactSave>
</env:Body>
</env:Envelope>

And here is a soap request that works ::

<?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>
- <ContactSave xmlns="http://inovaware.com/prism/">
- <contact>
<ContactKey xsi:nil="true" />
<ContactID />
<NamePrefix />
<NameTitle />
<FirstName>WesTest</FirstName>
<LastName>ShaddixTest</LastName>
<NameSuffix />
<Pronunciation />
<JobTitle />
<Company />
<AddressLine1 />
<AddressLine2 />
<City />
<MailRegion />
<MailCode />
<Country />
<WorkNumber />
<FAXNumber />
<HomeNumber />
<MobileNumber />
<PagerNumber />
<EMailAddress />
<BirthDate xsi:nil="true" />
<Login />
<Password />
<ModifyCount>0</ModifyCount>
</contact>
</ContactSave>
</soap:Body>
</soap:Envelope>

I need to figure out how to change the namespace names of the envelope,
body, and ContactSave elements and it *should* work I think.

Thanks for the help.

-----Original Message-----
From: NAKAMURA, Hiroshi [mailto:[email protected]]
Sent: Thursday, October 27, 2005 8:41 PM
To: ruby-talk ML
Subject: Re: Soap::RPC::Driver Question

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Wes said:
How do you make the soap client send utf-8 encoded instead of ascii encoded
requests?

Set $KCODE = 'UTF8' if you don't have iconv or uconv been installed.
Soap4r should detect iconv and uconv and use utf-8 by itself.

i.e.
$KCODE = 'UTF8'
drv = ...
or
ruby -Ku myclient.rb
How do you keep the request serialization from including the data type of
each element?

Please set Driver#generate_explicit_type = false.

i.e.

drv = SOAP::RPC::Driver.new(...)
drv.add_method('my_method', ...)
drv.generate_explicit_type = false
drv.my_method(...)

Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDYXN5f6b33ts2dPkRApKxAKDAV0ZOIgb08lXsBYdYB9r6rfzKLwCfcM66
i0f7rTV9iZwGq3rzTFuNkWY=
=gLgO
-----END PGP SIGNATURE-----
 
Ad

Advertisements

N

NAKAMURA, Hiroshi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Wes said:
Update:: I've got most everything correct now, I just have to figure out how
to control the namespace names. Here is my current code :

There's no easy way to control the namespace names for now.

Your server is not using XML parser (such as ad-hoc pattern matching) so
it cannot handle XML Namespace, right? All soap node implementations I
ever seen handle XML Namespace correctly, at least about SOAP message
handling. You should be in doubt about other problems if you're using
general soap node implementation.

'env' definition is in soap/soap.rb.

SOAPNamespaceTag = 'env'

You can add something like;

module SOAP
remove_const:)SOAPNamespaceTag)
SOAPNamespaceTag = 'soap'
end

but you should not do it. Further fast that controlling 'n1' is harder.
You must rewrite xsd/ns.rb.

Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDYq5Lf6b33ts2dPkRAowxAJwP0BeKCp2ewGj3D7TJgGYOU5cdMQCfYIys
m1fpCnHLS6WJd1nZ0dzZwcg=
=n0fh
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top