Problema com Web Service

Olá, tento acessar um Web Service ja pronto, e está dando erro, alguem pode me ajudar?
Segue o código de acesso:

public class ClienteServico {
public static void main(String[] args) {

	System.setProperty("http.proxyHost", "200.214.130.55"); 
	System.setProperty("http.proxyPort", "9443"); 
	
	Date dt = new Date();
	SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
	String data = "16/02/2012";
	Calendar c = format.getCalendar();
	MedicamentoDTO[] m = new MedicamentoDTO[2];
	MedicamentoDTO v = new MedicamentoDTO();
	SolicitacaoDTO s = new SolicitacaoDTO();
	UsuarioFarmaciaDTO u = new UsuarioFarmaciaDTO();
	AutorizacaoDTO a = new AutorizacaoDTO();

	v.setCoCodigoBarra("78961121114185");
	v.setQtSolicitada(1);
	v.setVlPrecoVenda(9.59);
	v.setQtPrescrita(30);

	m[0] = v;

	s.setCoSolicitacaoFarmacia("1");
	s.setNuCnpj("111");
	s.setNuCpf("392.347.518-02");
	s.setNuCrm("23218");
	s.setSgUfCrm("SP");
	s.setDtEmissaoReceita(c);
	s.setDnaEstacao("");
	s.setArrMedicamentoDTO(m);

	u.setUsuarioFarmacia("6546120");
	u.setSenhaFarmacia("39331");
	u.setUsuarioVendedor("342.811.888.19");
	u.setSenhaVendedor("1238");
                            Properties env = new Properties();   
                            env.put(Context.SECURITY_PRINCIPAL, "guest" );   
                           env.put(Context.SECURITY_CREDENTIALS, "guest" );           
                           env.put(Context.INITIAL_CONTEXT_FACTORY,"java.naming.factory.initial");
                          env.put(Context.PROVIDER_URL, "http://200.214.130.55:9443");  
	
	try {  
                                Context context = new InitialContext(env);  
                                ServicoSolicitacaoWSSoapBindingStub soap = (ServicoSolicitacaoWSSoapBindingStub) context.lookup("FarmaciaPopular/remote"); 
                                  a = soap.executarSolicitacao(s, u);

    } catch (NamingException e) {  
        e.printStackTrace();  
    } catch (RemoteException e) {  
        e.printStackTrace();  
    }
	
}

}

Segue o Erro:

javax.naming.NoInitialContextException: Cannot instantiate class: java.naming.factory.initial [Root exception is java.lang.ClassNotFoundException: java.naming.factory.initial]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.(Unknown Source)
at comunicacaoWebervice.ClienteServico.main(ClienteServico.java:78)
Caused by: java.lang.ClassNotFoundException: java.naming.factory.initial
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
… 5 more

troque isso:

java.naming.factory.initial

por isso

com.sun.jndi.ldap.LdapCtxFactory

e faça um teste.

[]'s

Oi, valeu pela atenção cara…
mudei e deu outro erro:

javax.naming.NamingException: Cannot parse url: http://200.214.130.55:9443 [Root exception is java.net.MalformedURLException: Not an LDAP URL: http://200.214.130.55:9443]
at com.sun.jndi.ldap.LdapURL.(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.(Unknown Source)
at comunicacaoWebervice.ClienteServico.main(ClienteServico.java:81)
Caused by: java.net.MalformedURLException: Not an LDAP URL: http://200.214.130.55:9443
… 10 more

fala do IP do serviço, mas o IP esta certo :S

tente trocar o http:// por ldap://

Ou erro agora:

javax.naming.ServiceUnavailableException: 200.214.130.55:9443; socket closed
at com.sun.jndi.ldap.Connection.readReply(Unknown Source)
at com.sun.jndi.ldap.LdapClient.ldapBind(Unknown Source)
at com.sun.jndi.ldap.LdapClient.authenticate(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.(Unknown Source)
at comunicacaoWebervice.ClienteServico.main(ClienteServico.java:81)

esse erro ae eh q o servidor esta indisponivel.

ele esta on line? o endereço esta correto?

nao sei se esse servico eh publico, mas tentei “pingar” ele e esta off line. talvez seja por isso.

Cara, creio que sim, é da Farmacia Popular…
O endereço é esse
https://200.214.130.55:9443/farmaciapopular/services/ServicoSolicitacaoWS?wsdl

o problema eh p endereco que vc esta passando. essas URLs são sensiveis a caixa alta, tente passar o nome em minusculo igual esta na url que vc me passou.

uma pergunta, vc usou alguma ferramenta para gerar as classes java? ex: wsimport, apache, etc.

Não, criei pelo eclipse mesmo o WS client importei, e automaticamente gerou as classes do servico…

Cara, meu projeto é desktop, tem alguma coisa a v??

vc pode usar em desktop normalmente.

tente fazer um teste usando os metodos diretamente, assim:

ServicoSolicitacaoWS service = new ServicoSolicitacaoWSServiceLocator().getServicoSolicitacaoWS(); service.confirmarAutorizacao(in0, in1) service.confirmarRecebimento(in0, in1) service.executarEstorno(in0, in1) service.executarSolicitacao(in0, in1) service.pesquisarAutorizacoes(in0, in1)

coloquei assim:

Properties env = new Properties();
env.put(Context.SECURITY_PRINCIPAL, “guest”);
env.put(Context.SECURITY_CREDENTIALS, “guest”);
env.put(Context.INITIAL_CONTEXT_FACTORY,
“com.sun.jndi.ldap.LdapCtxFactory”);
env.put(Context.PROVIDER_URL, “ldap://200.214.130.55:9443”);

	try {
		ServicoSolicitacaoWS service;
		try {
			service = new ServicoSolicitacaoWSServiceLocator()
					.getServicoSolicitacaoWS();
			service.executarSolicitacao(s, u);
		} catch (ServiceException e) {
			e.printStackTrace();
		}
	} catch (RemoteException e) {
		e.printStackTrace();
	}

e eu deu esses erros:

15/02/2012 08:25:20 org.apache.axis.utils.JavaUtils isAttachmentSupported
WARNING: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.io.IOException: Unexpected EOF from proxy
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.io.IOException: Unexpected EOF from proxy
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:156)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at org.datasus.service.ServicoSolicitacaoWSSoapBindingStub.executarSolicitacao(ServicoSolicitacaoWSSoapBindingStub.java:318)
at comunicacaoWebervice.ClienteServico.main(ClienteServico.java:87)

{http://xml.apache.org/axis/}hostname:RodrigoP

java.io.IOException: Unexpected EOF from proxy
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at org.datasus.service.ServicoSolicitacaoWSSoapBindingStub.executarSolicitacao(ServicoSolicitacaoWSSoapBindingStub.java:318)
at comunicacaoWebervice.ClienteServico.main(ClienteServico.java:87)
Caused by: java.io.IOException: Unexpected EOF from proxy
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:156)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
… 11 more

esse codigo nao eh necessario

Properties env = new Properties(); env.put(Context.SECURITY_PRINCIPAL, "guest"); env.put(Context.SECURITY_CREDENTIALS, "guest"); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://200.214.130.55:9443");

entendi, mas continua com o mesmo erro…
Sera que é alguma configuração que eu não fiz?? :S

fiz um teste aqui e ele reclamou de certificado, esse serviço tem alguma coisa desse tipo?

não, que eu saiba não, no site não fala nada sobre isso…
Esse é o site que fornece o serviço…
https://aplicacao.saude.gov.br/portalfarmacia/ajuda/protocolo.jsf

pesquisei e tem certificado sim, vc vai precisar correr atras disso tbm.
depois que vc tiver instalado ele, o codigo para consumir o webservice eh simples assim:

try { ServicoSolicitacaoWS service = new ServicoSolicitacaoWSServiceLocator().getServicoSolicitacaoWS(); SolicitacaoDTO sdto = new SolicitacaoDTO(); //sdto.set... todos os sets necessarios UsuarioFarmaciaDTO udto = new UsuarioFarmaciaDTO(); //udto.set... todos os sets necessarios service.executarSolicitacao(sdto, udto); } catch (Exception e) { e.printStackTrace(); }

[]'s