Note: This is not an answer, but a detailed analysis of the request.
I just tested this web-service.
To do so I added the same through a Web Reference and I called it as follows:
var token = String.Empty;
var validade = String.Empty;
var erro = default(UraService.erro);
try
{
var cliente = new UraService.SoapUraClient();
cliente.Endpoint.EndpointBehaviors.Add(new SimpleEndpointBehavior());
token = cliente.GetToken(1234567890, 2, "1.0", out validade, out erro);
}
catch (Exception err)
{
Debugger.Break();
}
Debugger.Break();
This Behavior has the sole purpose of inspecting the messages being sent and received. It follows below its implementation:
Simpleendpointbehavior
public class SimpleEndpointBehavior : IEndpointBehavior
{
public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(new SimpleMessageInspector());
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
}
Simplemessageinspector
public class SimpleMessageInspector : IClientMessageInspector
{
public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
{
var xml = reply.ToString();
Debugger.Break();
}
public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)
{
var xml = request.ToString();
Debugger.Break();
return null;
}
}
Request is being sent as follows:
Soapuraservice - Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">get_token</Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetToken xmlns="http://omnifacil3.omni.com.br/desenv">
<cnpjParceiro xmlns="">1234567890</cnpjParceiro>
<codigoParceiro xmlns="">2</codigoParceiro>
<versaoWS xmlns="">1.0</versaoWS>
</GetToken>
</s:Body>
</s:Envelope>
And below the received answer:
Soapuraservice - Response
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
<soap:Body>
<Response xmlns="http://omnifacil3.omni.com.br/desenv">
<GetToken>
<CodToken>499935661838159</CodToken>
<ValidadeToken>12/02/2015 23:59:59</ValidadeToken>
</GetToken></Response>
</soap:Body>
</soap:Envelope>
I believe the WCF Client is having trouble deserializing the message, so it is assigning null to token, validity and error.
If you look in the WSDL file, you will find the following snippets:
WSDL
<portType name="SoapUra">
<operation name="GetToken">
<input message="tns:GetToken"/>
<output message="tns:GetTokenResponse"/>
</operation>
<operation name="GetDadosAgente">
<input message="tns:GetDadosAgente"/>
<output message="tns:GetDadosAgenteResponse"/>
</operation>
</portType>
...
<xs:complexType name="GetToken">
<xs:sequence>
<xs:element name="cnpjParceiro" type="xs:int" minOccurs="1" maxOccurs="1"/>
<xs:element name="codigoParceiro" type="xs:int" minOccurs="1" maxOccurs="1"/>
<xs:element name="versaoWS" minOccurs="1" maxOccurs="1">...</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="GetTokenResponse">
<xs:sequence>
<xs:element name="CodToken" minOccurs="0" maxOccurs="1">...</xs:element>
<xs:element name="ValidadeToken" minOccurs="0" maxOccurs="1">...</xs:element>
<xs:element name="erro" type="tns:erro" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
Soapuraservice - Expected Response
It should be noted that Response is in a different format than expected by the Customer.
Below follows the XML Expected:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
<soap:Body>
<GetTokenResponse xmlns="http://omnifacil3.omni.com.br/desenv">
<CodToken>499935661838159</CodToken>
<ValidadeToken>12/02/2015 23:59:59</ValidadeToken>
</GetTokenResponse>
</soap:Body>
</soap:Envelope>
Finally, I set up a WCF Service that mimics what you are trying to access, it returned me the Token and Validadetoken without problems, I will put down the sending and receiving messages only for comparison purposes:
Wstest - Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IService1/GetToken</Action>
</s:Header>
<s:Body>
<GetToken xmlns="http://tempuri.org/">
<cnpjParceiro>1234567890</cnpjParceiro>
<codigoParceiro>2</codigoParceiro>
<versaoWS>1.0</versaoWS>
</GetToken>
</s:Body>
</s:Envelope>
Wstest - Response
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<GetTokenResponse xmlns="http://tempuri.org/">
<GetTokenResult>499935661838159</GetTokenResult>
<ValidadeToken>12/02/2015 23:59:59</ValidadeToken>
<erro i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/WcfService1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />
</GetTokenResponse>
</s:Body>
</s:Envelope>
tried to add as Service Reference?
– Tobias Mesquita
Yes, I tried as Service Reference and sending XML with Webrequest. If you want, you can try to run, I left the parameters in the code.
– Jean Gustavo Prates
gave problem enconding XML, the same was using iso-8859-1. You can see the following answer: http://stackoverflow.com/questions/1908030/calling-a-webservice-that-uses-iso-8859-1-encoding-from-wcf
– Tobias Mesquita
He changed the format to UTF-8, but now the return is null. Using SOAPUI gets the return normally, which can be?
– Jean Gustavo Prates