Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Dodavanje AuthenticationHeader -a u SOAP Header

[es] :: Java :: Dodavanje AuthenticationHeader -a u SOAP Header

[ Pregleda: 4660 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

kpknb

Član broj: 257578
Poruke: 8
*.mediaworksit.net.



Profil

icon Dodavanje AuthenticationHeader -a u SOAP Header22.04.2010. u 12:03 - pre 143 meseci
Kako se modifikuje SOAP Header?

Potrebno je da ubacim AuthenticationHeader sa podacima koje sam dobio od NBS.

Code:
<soap:Header>
    <AuthenticationHeader xmlns="http://communicationoffice.nbs.rs">
      <UserName>string</UserName>
      <Password>string</Password>
      <LicenceID>guid</LicenceID>
    </AuthenticationHeader>
  </soap:Header>


Kod kojim se poziva web servis za tekucu kursnu listu (generisan u NetBeansu) :

Code:
 try { // Call Web Service Operation
        rs.nbs.communicationoffice.ExchangeRateXmlService service = new rs.nbs.communicationoffice.ExchangeRateXmlService();
        rs.nbs.communicationoffice.ExchangeRateXmlServiceSoap port = service.getExchangeRateXmlServiceSoap12();
        // TODO initialize WS operation arguments here
        int exchangeRateListTypeID = 0;
        // TODO process result here
        java.lang.String result = port.getCurrentExchangeRate(exchangeRateListTypeID);
        System.out.println("Result = "+result);
    } catch (Exception ex) {
        // TODO handle custom exceptions here
    }

 
Odgovor na temu

reg
java,java,java
bgd

Član broj: 249663
Poruke: 30
*.mediaworksit.net.



Profil

icon Re: Dodavanje AuthenticationHeader -a u SOAP Header23.04.2010. u 15:36 - pre 143 meseci
ClientAuthenticator.java

Ideja je da ne diras src code koji je Netbeans izgenerisao vec
da dodas ovaj auth. header pomocu ove klase.



 
Odgovor na temu

kpknb

Član broj: 257578
Poruke: 8
*.mediaworksit.net.



Profil

icon Re: Dodavanje AuthenticationHeader -a u SOAP Header04.05.2010. u 14:40 - pre 142 meseci
Posto sam koristio jax-ws, naisao sam na ovo resenje:
Code:
import com.sun.xml.ws.developer.WSBindingProvider;

HelloPort port = helloService.getHelloPort();  // or something like that...
WSBindingProvider bp = (WSBindingProvider)port;

bp.setOutboundHeader(
  // simple string value as a header, like <simpleHeader>stringValue</simpleHeader>
  Headers.create(new QName("simpleHeader"),"stringValue"),
  // create a header from JAXB object
  Headers.create(jaxbContext,myJaxbObject)
);
 
Odgovor na temu

ilkeNo1
Miloš Ilić
bg

Član broj: 37476
Poruke: 111
*.adsl-a-8.sezampro.rs.



+2 Profil

icon Re: Dodavanje AuthenticationHeader -a u SOAP Header12.08.2010. u 01:53 - pre 139 meseci
Da li moze nek da me uputi detaljnije kako se implementiraju web servisi nbs-a u javi, ako se apache cxf-om izgenerisu stub klase?

Kako se implementira biznis logika tih klasa? Da li su one samo poo sebi dovoljne ili moraju da se pisu neki iinterceptori za soap header-e?

Inace, nisam do sada implementirao web servise.

Hvala unapreed
"Izgubljeno je samo ono cega se odreknemo"
 
Odgovor na temu

cubrovic
home
Beograd

Član broj: 27259
Poruke: 179
*.adsl.verat.net.

Jabber: cubrovic


+9 Profil

icon Re: Dodavanje AuthenticationHeader -a u SOAP Header24.08.2010. u 18:21 - pre 139 meseci
Koristim axis (eclipse izgenerisao klijentske klase na osnovu wsdl-a)
Napravim hedar i umetnem ga na prozy pre nego sto pozovem metodu koju hocu.

...
ExchangeRateXmlServiceSoapProxy exchangeRateXmlServiceSoapProxy = new ExchangeRateXmlServiceSoapProxy(endpoint);
ExchangeRateXmlServiceSoap exchangeRateXmlServiceSoap = exchangeRateXmlServiceSoapProxy.getExchangeRateXmlServiceSoap();
SOAPHeaderElement ah = createHeader();
org.apache.axis.client.Stub stub = (org.apache.axis.client.Stub) exchangeRateXmlServiceSoap;
stub.setHeader(ah);
...

ispod je kompletan kod


public class CommandGetDataFromWS {
public static void main(String[] args) {
String endpoint = "https://webservices.nbs.rs/Com..._0/ExchangeRateXmlService.asmx";
ExchangeRateXmlServiceSoapProxy exchangeRateXmlServiceSoapProxy = new ExchangeRateXmlServiceSoapProxy(endpoint);
ExchangeRateXmlServiceSoap exchangeRateXmlServiceSoap = exchangeRateXmlServiceSoapProxy.getExchangeRateXmlServiceSoap();
SOAPHeaderElement ah = createHeader();
org.apache.axis.client.Stub stub = (org.apache.axis.client.Stub) exchangeRateXmlServiceSoap;
stub.setHeader(ah);
try {
exchangeRateXmlServiceSoapProxy.setEndpoint(endpoint);
String currentExchangeRate = exchangeRateXmlServiceSoapProxy.getCurrentExchangeRate(1);

System.out.println(currentExchangeRate);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

static SOAPHeaderElement createHeader() {
try {
String PREFIX="http://communicationoffice.nbs.rs";

SOAPHeaderElement ah= new SOAPHeaderElement(new QName("AuthenticationHeader"));
ah.addNamespaceDeclaration("", PREFIX);

ah.setNamespaceURI(PREFIX);

SOAPElement node = ah.addChildElement("UserName");
node.addTextNode("nnn");

SOAPElement node2 = ah.addChildElement("Password");
node2.addTextNode("nnn");

SOAPElement node3 = ah.addChildElement("LicenceID");
node3.addTextNode("nnn-nnn-nnn-nnn-nnn");

System.out.println(ah.getAsString());

return ah;
} catch (SOAPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}

 
Odgovor na temu

[es] :: Java :: Dodavanje AuthenticationHeader -a u SOAP Header

[ Pregleda: 4660 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.