Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# struct and NuSOAP(php)

C# struct and NuSOAP(php)

Scheduled Pinned Locked Moved C#
wcfcsharpphpcomsysadmin
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    OptiPlex
    wrote on last edited by
    #1

    Hello Im trying to build a client in c# that talks with some remote (php)server with SOAP using the NuSOAP library. Here im using a struct/object that will containt the user info of some user:

    public struct UserProfile {
    public string username;
    public string password;
    public string email;
    public string site;
    public string signature;
    public int age;
    public int points;

    And this is the PHP Code:

    server->wsdl->addComplexType(
    'UserProfile',
    'complexType',
    'struct',
    'all',
    '',
    array(
    'username' => array('name' => 'username', 'type' => 'xsd:string'),
    'password' => array('name' => 'password', 'type' => 'xsd:string'),
    'email' => array('name' => 'email', 'type' => 'xsd:string'),
    'site' => array('name' => 'site', 'type' => 'xsd:string'),
    'signature' => array('name' => 'signature', 'type' => 'xsd:string'),
    'age' => array('name' => 'age', 'type' => 'xsd:int'),
    'points' => array('name' => 'username', 'type' => 'xsd:int'),
    )
    );

    $server->wsdl->addComplexType(
    'UserProfileArray',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:UserProfile[]')),
    'tns:UserProfile'
    );

    $server->register("getUserProfile",
    array(),
    array('return' => 'tns:UserProfileArray'),
    $namespace,
    false,
    'rpc',
    false,
    'Get the user profile object'
    );

    function getUserProfile(){
    $profile['username'] = "user";
    $profile['password'] = "pass";
    $profile['email'] = "usern@ame";
    $profile['site'] = "u.com";
    $profile['signature'] = "usucsdckme";
    $profile['age'] = 111;
    $profile['points'] = time() / 2444;

    return $profile;
    

    }

    Now I already have a working login function, and I want to get the info about the logged in user but I dont know howto obtain these. This is what im using to get the userinfo:

            string user = txtUser.Text;
            string pass = txtPass.Text;
            SimpleService.SimpleService service = new SimpleService.SimpleService();
            if(service.login(user, pass)){
                 //logged in
    
            }
    
            SoapApp.SimpleService.UserProfile\[\] user = service.getUserProfile(); // THIS LINE GIVES ME AN EXCEPTION
    
            MessageBox.Show(user\[0\].username + "--" + user\[0\].p
    
    D A 2 Replies Last reply
    0
    • O OptiPlex

      Hello Im trying to build a client in c# that talks with some remote (php)server with SOAP using the NuSOAP library. Here im using a struct/object that will containt the user info of some user:

      public struct UserProfile {
      public string username;
      public string password;
      public string email;
      public string site;
      public string signature;
      public int age;
      public int points;

      And this is the PHP Code:

      server->wsdl->addComplexType(
      'UserProfile',
      'complexType',
      'struct',
      'all',
      '',
      array(
      'username' => array('name' => 'username', 'type' => 'xsd:string'),
      'password' => array('name' => 'password', 'type' => 'xsd:string'),
      'email' => array('name' => 'email', 'type' => 'xsd:string'),
      'site' => array('name' => 'site', 'type' => 'xsd:string'),
      'signature' => array('name' => 'signature', 'type' => 'xsd:string'),
      'age' => array('name' => 'age', 'type' => 'xsd:int'),
      'points' => array('name' => 'username', 'type' => 'xsd:int'),
      )
      );

      $server->wsdl->addComplexType(
      'UserProfileArray',
      'complexType',
      'array',
      '',
      'SOAP-ENC:Array',
      array(),
      array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:UserProfile[]')),
      'tns:UserProfile'
      );

      $server->register("getUserProfile",
      array(),
      array('return' => 'tns:UserProfileArray'),
      $namespace,
      false,
      'rpc',
      false,
      'Get the user profile object'
      );

      function getUserProfile(){
      $profile['username'] = "user";
      $profile['password'] = "pass";
      $profile['email'] = "usern@ame";
      $profile['site'] = "u.com";
      $profile['signature'] = "usucsdckme";
      $profile['age'] = 111;
      $profile['points'] = time() / 2444;

      return $profile;
      

      }

      Now I already have a working login function, and I want to get the info about the logged in user but I dont know howto obtain these. This is what im using to get the userinfo:

              string user = txtUser.Text;
              string pass = txtPass.Text;
              SimpleService.SimpleService service = new SimpleService.SimpleService();
              if(service.login(user, pass)){
                   //logged in
      
              }
      
              SoapApp.SimpleService.UserProfile\[\] user = service.getUserProfile(); // THIS LINE GIVES ME AN EXCEPTION
      
              MessageBox.Show(user\[0\].username + "--" + user\[0\].p
      
      D Offline
      D Offline
      dataminers
      wrote on last edited by
      #2

      Ok, php and .net are different platform. So data structers are different. Normally different platform can not talk each other. If we talk about windows side; windows solve this problem with WCF (Window Communication Foundation). On java side; Sun's Project Tango http://java.sun.com/developer/technicalArticles/glassfish/ProjectTango/[^] But your server side is PHP. How to solve I don't know. May you can parse XML format. I know it is not good solution but you can solve using XML parsing. Best Regards...

      O A 2 Replies Last reply
      0
      • D dataminers

        Ok, php and .net are different platform. So data structers are different. Normally different platform can not talk each other. If we talk about windows side; windows solve this problem with WCF (Window Communication Foundation). On java side; Sun's Project Tango http://java.sun.com/developer/technicalArticles/glassfish/ProjectTango/[^] But your server side is PHP. How to solve I don't know. May you can parse XML format. I know it is not good solution but you can solve using XML parsing. Best Regards...

        O Offline
        O Offline
        OptiPlex
        wrote on last edited by
        #3

        Thank you sir Parsing XML/String, I can live with that. Thanks again, - opx

        D 1 Reply Last reply
        0
        • O OptiPlex

          Thank you sir Parsing XML/String, I can live with that. Thanks again, - opx

          D Offline
          D Offline
          dataminers
          wrote on last edited by
          #4

          Your welcome.

          1 Reply Last reply
          0
          • O OptiPlex

            Hello Im trying to build a client in c# that talks with some remote (php)server with SOAP using the NuSOAP library. Here im using a struct/object that will containt the user info of some user:

            public struct UserProfile {
            public string username;
            public string password;
            public string email;
            public string site;
            public string signature;
            public int age;
            public int points;

            And this is the PHP Code:

            server->wsdl->addComplexType(
            'UserProfile',
            'complexType',
            'struct',
            'all',
            '',
            array(
            'username' => array('name' => 'username', 'type' => 'xsd:string'),
            'password' => array('name' => 'password', 'type' => 'xsd:string'),
            'email' => array('name' => 'email', 'type' => 'xsd:string'),
            'site' => array('name' => 'site', 'type' => 'xsd:string'),
            'signature' => array('name' => 'signature', 'type' => 'xsd:string'),
            'age' => array('name' => 'age', 'type' => 'xsd:int'),
            'points' => array('name' => 'username', 'type' => 'xsd:int'),
            )
            );

            $server->wsdl->addComplexType(
            'UserProfileArray',
            'complexType',
            'array',
            '',
            'SOAP-ENC:Array',
            array(),
            array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:UserProfile[]')),
            'tns:UserProfile'
            );

            $server->register("getUserProfile",
            array(),
            array('return' => 'tns:UserProfileArray'),
            $namespace,
            false,
            'rpc',
            false,
            'Get the user profile object'
            );

            function getUserProfile(){
            $profile['username'] = "user";
            $profile['password'] = "pass";
            $profile['email'] = "usern@ame";
            $profile['site'] = "u.com";
            $profile['signature'] = "usucsdckme";
            $profile['age'] = 111;
            $profile['points'] = time() / 2444;

            return $profile;
            

            }

            Now I already have a working login function, and I want to get the info about the logged in user but I dont know howto obtain these. This is what im using to get the userinfo:

                    string user = txtUser.Text;
                    string pass = txtPass.Text;
                    SimpleService.SimpleService service = new SimpleService.SimpleService();
                    if(service.login(user, pass)){
                         //logged in
            
                    }
            
                    SoapApp.SimpleService.UserProfile\[\] user = service.getUserProfile(); // THIS LINE GIVES ME AN EXCEPTION
            
                    MessageBox.Show(user\[0\].username + "--" + user\[0\].p
            
            A Offline
            A Offline
            Almighty Bob
            wrote on last edited by
            #5

            change

            $server->register("getUserProfile",
            array(),
            array('return' => 'tns:UserProfileArray'),
            $namespace,
            false,
            'rpc',
            false,
            'Get the user profile object'
            );

            to

            $server->register("getUserProfile",
            array(),
            array('return' => 'tns:UserProfile'),
            $namespace,
            false,
            'rpc',
            false,
            'Get the user profile object'
            );

            to return one profile. There's no point in defining an array of user profiles if all you want to return is one.


            my super duper cool website

            1 Reply Last reply
            0
            • D dataminers

              Ok, php and .net are different platform. So data structers are different. Normally different platform can not talk each other. If we talk about windows side; windows solve this problem with WCF (Window Communication Foundation). On java side; Sun's Project Tango http://java.sun.com/developer/technicalArticles/glassfish/ProjectTango/[^] But your server side is PHP. How to solve I don't know. May you can parse XML format. I know it is not good solution but you can solve using XML parsing. Best Regards...

              A Offline
              A Offline
              Almighty Bob
              wrote on last edited by
              #6

              dataminers wrote:

              Ok, php and .net are different platform. So data structers are different. Normally different platform can not talk each other.

              that's totally incorrect. the whole point of service oriented architectures is so that disparate systems can work together. C# can talk to java, java can talk to php, php can talk to C# and vice versa. it doesn't matter what the source or destination languages are, as long as they can serialize/encode and deserialize/decode an http request / response to and from SOAP.


              my super duper cool website

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups