Naum estou conseguindo consumir WS java em delphi 7

Delphi

10/11/2011

Ola pessoal,

Naum estou conseguindo consumir o WS q fiz em java no delphi 7. Ja mudei para uma nova versao a parte do wsdl import acessando o site da embarcadero. Mas continua dando este erro qdo eu executo:

First chance exception at $76FFB727. Exception class ERemotableException with message Cannot find dispatch method for {}nome. Process Project1.exe (6776)

//////////////////////////////////////////////////////////////////////////////////
Agradeço a atenção de vcs e se possivel, alguem puder me ajudar... Eliana


//////////////////////////////////////////////////////////////////////////////////
Meu codigo em java no netbeans (estou usando glassfish 3, java ee 6):

package pacote;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.soap.SOAPBinding;

@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class WShola {

@WebMethod
public String helloNome(@WebParam(name = nome) String nome) {
return Hello World JAX-WS + nome;
}
}
//////////////////////////////////////////////////////////////////////////////////
a wsdl gerada:

<!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RIs version is Metro/2.1.1-b09 (branches/2.1-6834; 2011-07-16T17:14:48+0000) JAXWS-RI/2.2.5-promoted-b04 JAXWS/2.2.
-->

<!--
Generated by JAX-WS RI at http://jax-ws.dev.java.net. RIs version is Metro/2.1.1-b09 (branches/2.1-6834; 2011-07-16T17:14:48+0000) JAXWS-RI/2.2.5-promoted-b04 JAXWS/2.2.
-->

<definitions targetNamespace=http://pacote/ name=WSholaService>
<types/>

<message name=helloNome>
<part name=nome type=xsd:string/>
</message>

<message name=helloNomeResponse>
<part name=return type=xsd:string/>
</message>

<portType name=WShola>

<operation name=helloNome>
<input wsam:Action=http://pacote/WShola/helloNomeRequest message=tns:helloNome/>
<output wsam:Action=http://pacote/WShola/helloNomeResponse message=tns:helloNomeResponse/>
</operation>
</portType>

<binding name=WSholaPortBinding type=tns:WShola>
<soap:binding transport=http://schemas.xmlsoap.org/soap/http style=rpc/>

<operation name=helloNome>
<soap:operation soapAction=/>

<input>
<soap:body use=literal namespace=http://pacote//>
</input>

<output>
<soap:body use=literal namespace=http://pacote//>
</output>
</operation>
</binding>

<service name=WSholaService>

<port name=WSholaPort binding=tns:WSholaPortBinding>
<soap:address location=http://localhost:8080/WShello/WSholaService/>
</port>
</service>
</definitions>

//////////////////////////////////////////////////////////////////////////////////
Abaixo segue a logica gerada pelo delphi:

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : C:\Users\eliana\Desktop\WSholaService.xml
// Encoding : UTF-8
// Codegen : [wfDebug,wfUseSerializerClassForAttrs]
// Version : 1.0
// (09/11/2011 23:53:30 - 1.33.2.5)
// ************************************************************************ //

unit WSholaService;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - http://www.w3.org/2001/XMLSchema


// ************************************************************************ //

// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : WSholaPortBinding
// service : WSholaService
// port : WSholaPort
// URL : http://localhost:8080/WShello/WSholaService
// ************************************************************************ //
WShola = interface(IInvokable)
[{B86B394C-2660-B1BD-796A-211947DBB3E7}]
function helloNome(const nome: WideString): WideString; stdcall;
end;

function GetWShola(UseWSDL: Boolean=System.False; Addr: string=; HTTPRIO: THTTPRIO = nil): WShola;


implementation

function GetWShola(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): WShola;
const
defWSDL = C:\Users\eliana\Desktop\WSholaService.xml;
defURL = http://localhost:8080/WShello/WSholaService;
defSvc = WSholaService;
defPrt = WSholaPort;
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = ) then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as WShola);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;


initialization
InvRegistry.RegisterInterface(TypeInfo(WShola), http://pacote/, UTF-8);
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WShola), );
InvRegistry.RegisterInvokeOptions(TypeInfo(WShola), ioLiteral);

end.

//////////////////////////////////////////////////////////////////////////////////
logica do button:

uses WSholaService;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
ws: WShola;
begin
ws := GetWShola(false, , HTTPRIO1);
Label1.Caption:= ws.helloNome(teste);

end;
//////////////////////////////////////////////////////////////////////////////////



Fund. Agronegócio

Fund. Agronegócio

Curtidas 0

Respostas

Éden Vasconcélos

Éden Vasconcélos

10/11/2011

Muda a seguinte linha:
InvRegistry.RegisterInvokeOptions(TypeInfo(WShola), ioLiteral);
Para:
InvRegistry.RegisterInvokeOptions(TypeInfo(WShola), ioDefault);
GOSTEI 0
Éden Vasconcélos

Éden Vasconcélos

10/11/2011

Também na linha não é necessário parâmetro
ws := GetWShola(false, , HTTPRIO1);

Pode ser mudado para:
ws := GetWShola();

Pois ele vai criar o objeto automaticamente.

Depois de utilizar não esquecer:
ws:= nil;
GOSTEI 0
POSTAR