2009-03-10 23 views
3

soap4r ile çalışıyorum ve SOAP :: Header :: SimpleHandler'ı kullanmaya çalışıyorum, giden iletiye özel bir başlık koymaya çalışıyorum, ancak çalışamıyorumsoap4r özel başlıklar

<ServiceContext xmlns="http://context.core.datamodel.fs.documentum.emc.com/"> 
     <Identities xsi:type="RepositoryIdentity" userName="_USER_" password="_PWD_" repositoryName="_DOCBASE_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/> 
    </ServiceContext> 
:

dönmek için gerekenler
<n1:ServiceContext xmlns:n1="http://context.core.datamodel.fs.documentum.emc.com/" 
     env:mustUnderstand="0"> 
     <n1:Identities> 
     <n1:Username>username</n1:Username> 
     <n1:Password>password</n1:Password> 
     <n1:Docbase>Test</n1:Docbase> 
     </n1:Identities> 
    </n1:ServiceContext> 

şudur:

class ServiceContext < SOAP::Header::SimpleHandler 
    NAMESPACE = "http://context.core.datamodel.fs.documentum.emc.com/" 
    def initialize() 
    super(XSD::QName.new(NAMESPACE, 'ServiceContext')) 
    XSD::QName.new(nil, "Identities") 
    end 

    def on_simple_outbound 
    username = "username" 
    password = "password" 
    docbase = "Test" 
    return {"Identities" => {"Username" => username, "Password" => password, "Docbase" => docbase}} 
    end 
end 

döndürür: nasıl özelliklerini yerine olarak alt öğeleri içerecek şekilde olsun

Her türlü yardım büyük beğeni topluyor.

cevap

3

soap4r çok hoş değil. Ben rdocs abit etrafında dürttü ve sorununuzu düzeltmek için en basit yolu on_simple_outbound oluşturmak istediğiniz öğenin dize gösterimini döndürmek olurdu gibi görünüyor.

böylece yerine

return {"Identities" => {"Username" => username, "Password" => password, "Docbase" => docbase}} 

oluşturucu gibi bir şey kullanarak

%Q(<Identities xsi:type="RepositoryIdentity" userName="#{user}" password="#{password}" repositoryName="#{docbase}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>) 

deneyin, daha rubyish görünmesi, ama bu deneyebilirsiniz. Diğer seçenek ise yeni sabun kitaplıklarını araştırmak olabilirdi. handsoap ilginç görünüyor.

İlgili konular