2015-11-12 48 views
0

我有下面的模式:SOAP ::精簡版傳遞參數作爲類

<xs:schema  xmlns:tns="http://common.balance.contract.kernel.bgbilling.bitel.ru/"  xmlns:ns1="http://common.bitel.ru" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"targetNamespace="http://common.balance.contract.kernel.bgbilling .bitel.ru/"> 
    <xs:import namespace="http://common.bitel.ru" s chemaLocation="http://xxx:8080/bgbilling/executer/ru.bitel.bgbilling.kernel.contract.balance/PaymentService?xsd=1"/> 
    <xs:element name="BGException" type="tns:BGException"/> 
… 
    <xs:element name="paymentUpdate" type="tns:paymentUpdate"/> 
    <xs:element name="paymentUpdateResponse" type="tns:paymentUpdateResponse"/> 
    <xs:complexType name="BGException"> 
    <xs:sequence> 
    <xs:element name="message" type="xs:string" minOccurs="0"/> 
    <xs:element name="tag" type="xs:string" minOccurs="0"/> 
    </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="payment"> 
    <xs:complexContent> 
    <xs:extension base="tns:abstractBalanceBean"> 
    <xs:sequence/> 
    </xs:extension> 
    </xs:complexContent> 
    </xs:complexType> 
    <xs:complexType name="abstractBalanceBean" abstract="true"> 
    <xs:complexContent> 
    <xs:extension base="ns1:id"> 
    <xs:sequence> 
    <xs:element name="comment" type="xs:string" minOccurs="0"/> 
    </xs:sequence> 
    <xs:attribute name="contractId" type="xs:int" use="required"/> 
    <xs:attribute name="date" type="xs:dateTime"/> 
    <xs:attribute name="sum" type="xs:decimal"/> 
    <xs:attribute name="summa" type="xs:decimal"/> 
    <xs:attribute name="timeChange" type="xs:dateTime"/> 
    <xs:attribute name="typeId" type="xs:int" use="required"/> 
    <xs:attribute name="userId" type="xs:int" use="required"/> 
    </xs:extension> 
    </xs:complexContent> 
    </xs:complexType> 
    <xs:complexType name="paymentUpdate"> 
    <xs:sequence> 
    <xs:element name="payment" type="tns:payment" minOccurs="0"/> 
    <xs:element name="distribution" type="xs:string" minOccurs="0"/> 
    </xs:sequence> 
    </xs:complexType> 

請告訴我如何,我必須在發送的方法paymentUpdate參數(在Perl)?

$client->call('paymentUpdate'=>SOAP::Data->type("namesp1:paymentUpdate")->... 

寫什麼? 如何創建和發送期望的類型(paymentUpdate)?

回答

0

使用屬性,這裏是解決方案:

$wsdl = "http://xxxxxxxxxxxxxx:8080/bgbilling/executer/ru.bitel.bgbilling.kernel.contract.balance/PaymentService?wsdl"; 
     @comment = ("<comment>$comment</comment>"); 
     $authoriz = 'Basic '.encode_base64('login:password'); 
     #$SOAP::Constants::PREFIX_ENV = 'SOAP-ENV'; 
     #$SOAP::Constants::PREFIX_ENC = "SOAP-ENC"; 
     $client = SOAP::Lite->new(service=>$wsdl); 
     $client->proxy($wsdl); 
     $client->ns("http://common.balance.contract.kernel.bgbilling.bitel.ru/","ns1"); 
     $client->outputxml('true'); 
     $client->transport->http_request->headers->push_header('Authorization' => $authoriz); 
     $soap = $client->service($wsdl.'?wsdl'); 
     my $pm = SOAP::Data->new(name=>"payment"); 
     $pm->type("ts:payment"); 
     $pm->attr({ id => "$id", contractId=>"$cid", date=>"$dt", sum=>"$sum", summa=>"$sum", typeId=>"3", userId=>"0"}); 
     $pm->value(@comment); 
     print $client->call('paymentUpdate',$pm);