0

I'm stumped, probably because of not understanding something about soap services. When I create a service reference to the current public x12 health document submission service interface:

http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd

I get some classes that define what the body of the soap message can be, but I can't get a client proxy generated.

I would like to build my client with WCF, but in every example I find, they have an existing contract to generate a proxy. I don't have that luxury. The functions for the service are called via soap action.

I can manually generate the call with code similar to this post but the call is always rejected because the 'nonce is expired'.

The examples for WCF all have a nice contract in their WSDL so it seems simple, but it's useless code as I can't create any interface (automajically). For example, Rick Strahl's blog post answers many questions and seems great if you have a contract message to call. I would like to follow his approach but am stumped on creating the client (properly)!

So, I can build a legacy soap client with WSE 3, with guidance here from MSDN but aren't we supposed to use WCF now? Even the post tags here say WSE is a last resort option.

Am I missing something about creating the client proxy?

So my question boils down to this: How can I create the web service client proxy for a soap service with no contracts in WCF?

Maybe I'm not understanding something about calling soap services, and could really use some help.

[EDIT: another thought - might I make my own manually built contract and thus generate a proxy with that? Not sure of the effect on XML output to the soap web service..ie, would the call look normal]

Community
  • 1
  • 1
Robert Achmann
  • 1,986
  • 3
  • 40
  • 66
  • You need a WSDL, and don't ever use WSE. The XSD is not enough for calling a service. – John Saunders Dec 17 '14 at 17:25
  • The WSDL I supplied is the only one supplied. If I put ?wsdl after the vendor site I get "Error: Generic Error. Could not generate WSDL!" The Vendor imlements a Axis2 Web Service – Robert Achmann Dec 17 '14 at 17:51
  • I've created a sample project to demonstrate you a solution, please see my edited answer – polacekpavel Dec 17 '14 at 18:40
  • 1
    You didn't post a WSDL URL, only an XSD – John Saunders Dec 17 '14 at 18:43
  • 1
    Wsdl url is http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.wsdl and in sample project https://bitbucket.org/polacekpavel/servicestacksample/src/51ab86e5a06cecaf7e59a812380a65767f2ebb29/Service%20References/CoreRule/CORE.wsdl?at=master – polacekpavel Dec 17 '14 at 18:49

1 Answers1

1

You can check my sample project for this wsdl https://bitbucket.org/polacekpavel/servicestacksample/src

Or you can use ChannelFactory for that http://msdn.microsoft.com/library/ms576132(v=vs.110).aspx Assume you have this interface - change it to the real one.

[ServiceContract]               
public interface IMathService
{
    [OperationContract]
    int Add(int a,int b);
}

then you can call it at runtime with custom configuration of ABC(address,binding,contract)

   //define binding 
    //assume your binding using basicHttp, change it if you are using something else
    BasicHttpBinding myBinding = new BasicHttpBinding();           

    //define endpoint url (where service is deployed)
    EndpointAddress myEndpoint = new EndpointAddress("http://localhost:11234/MathService.svc"); //change to real endpoint 

    //Use channel factory instead of generated one
    ChannelFactory<IMathservice> myChannelFactory = new ChannelFactory<IMathservice>(myBinding, myEndpoint); //Change to you WCF interface
    IMathservice mathService= myChannelFactory.CreateChannel();

    //and call it            
    var result = mathService.Add(1,1); //input to your method

    ((IClientChannel)mathService).Close();
    myChannelFactory.Close();
polacekpavel
  • 431
  • 3
  • 9
  • That assumes that he knows the contract. All he has is an XSD describing the message formats. That's not a contract. – John Saunders Dec 17 '14 at 17:26
  • I think message format is at http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.wsdl and there is a data type descriptions http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd so I think that is enough information for call – polacekpavel Dec 17 '14 at 17:30
  • Then the OP should use "Add Service Reference" and refer to the WSDL. – John Saunders Dec 17 '14 at 17:35
  • Definitely. For me approach by channelFactory is more "clearer" than configuration hell and auto generated classes. But it's absolutely correct way to do this. – polacekpavel Dec 17 '14 at 17:43
  • I did "Add Service Reference" but it offers no client proxy or service call as a result - that would have been mega easy and I wouldn't have to have asked this question. @polacekpavel How would you make the call? There is only the soap body class definitions from that WSDL - no message. – Robert Achmann Dec 17 '14 at 17:48
  • At dialog "Add service reference" write url http://caqh.org/SOAP/WSDL/CORERule2.2.0.wsdl which is wsdl for this endpoint, this will generate proxy class and add configuration to you app.config/web.config then simple use generated proxy. CoreRule.CORETransactionsClient client = new CoreRule.CORETransactionsClient(); client.BatchResultsAckSubmitTransaction(new CoreRule.COREEnvelopeBatchResultsAckSubmission() { ReceiverID = 122, //... }); – polacekpavel Dec 17 '14 at 17:54
  • And dont forget to change URL at app.config/web.config for real one – polacekpavel Dec 17 '14 at 17:55
  • What the heck!?!? Every other time - EVERY OTHER TIME - I've done that, the References.cs file was empty...why would it suddenly work? NOW I have a client! Holy cow... Well, thanks though. In my disbelief, I just added it again from your link and it worked... – Robert Achmann Dec 17 '14 at 18:51
  • 1
    Yeah. I know that feeling. As the saying goes "Chuck Norris can configure WCF" :-) – polacekpavel Dec 17 '14 at 18:57